<div>Hi David</div>
<div>I did that, but the auto-increment field values starts from a high integer value (approx 15594). Then onwards for each row it is incremented by 1.</div>
<div>Though I do not see any problem with that (starting from high value), I would have liked the value to start from 0 or 1 and keep incrementing for each row.<br></div>
<div>Is there any-way, I can force the value to start from 0 or 1.</div>
<div> </div>
<div>Best Regards</div>
<div>Austin<br></div>
<div class="gmail_quote">On Mon, Mar 28, 2011 at 11:42 PM, Metzler, David <span dir="ltr"><<a href="mailto:metzlerd@evergreen.edu">metzlerd@evergreen.edu</a>></span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote"><br>Do not include cid in the insert statement and it should autoincrement for you.<br>
<div>
<div></div>
<div class="h5"><br>-----Original Message-----<br>From: <a href="mailto:support-bounces@drupal.org">support-bounces@drupal.org</a> on behalf of Austin Einter<br>Sent: Mon 3/28/2011 03:04<br>To: <a href="mailto:support@drupal.org">support@drupal.org</a>; <a href="mailto:development@drupal.org">development@drupal.org</a><br>
Subject: [support] How to get the auto-increment value<br><br>Hi All<br>I have a table, where 'cid' field is of type "serial".<br><br>Schema declaration is -> *"'cid' => array('type' => 'serial', 'unsigned' =><br>
TRUE, 'not null' => TRUE, ),"*<br><br>Aim is to have an incremented value for it.<br>The code is as below<br><br>*$lastid = 0;<br> for($delta = 0; $delta < $all_companies; $delta++)<br> {<br> $lastid = db_last_insert_id(rs_companies, cid) + 1;<br>
db_query(<br> 'INSERT INTO {rs_companies} ( cid, uid, prevcompany, joindate,<br>releasedate) '<br> ."VALUES (%d, '%d', '%s', '%d', '%d')",<br> $lastid, *<br><br>
With this, I find this 'cid' field is not auto incrementing. Any idea,<br>whats the wrong here.<br><br>Best Regards<br>Austin.<br><br></div></div><br>--<br>[ Drupal support list | <a href="http://lists.drupal.org/" target="_blank">http://lists.drupal.org/</a> ]<br>
</blockquote></div><br>