[development] How to get the auto-increment value

nan wich nan_wich at bellsouth.net
Mon Mar 28 10:50:52 UTC 2011


You don't need to provide the value for an auto increment field. 
"Db_last_insert_id()" is how you get the value after the insert, if you need it 
at all.
 
Nancy
 
Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.



________________________________

From: Austin Einter
I have a table, where 'cid' field is of type "serial".

$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,  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20110328/5591be49/attachment.html 


More information about the development mailing list