[development] How to get the auto-increment value

Austin Einter austin.einter at gmail.com
Mon Mar 28 10:04:50 UTC 2011


Hi All
I have a table, where 'cid' field is of type "serial".

Schema declaration is ->  *"'cid' => array('type' => 'serial', 'unsigned' =>
TRUE, 'not null' => TRUE, ),"*

Aim is to have an incremented value for it.
The code is as below

*$lastid = 0;
  for($delta = 0; $delta < $all_companies; $delta++)
  {
 $lastid = db_last_insert_id(rs_companies, cid) + 1;
      db_query(
    'INSERT INTO {rs_companies} ( cid, uid, prevcompany, joindate,
releasedate) '
      ."VALUES (%d, '%d', '%s', '%d', '%d')",
 $lastid,  *

With this, I find this 'cid' field is not auto incrementing.  Any idea,
whats the wrong here.

Best Regards
Austin.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20110328/b2ea3463/attachment.html 


More information about the development mailing list