RE: SQL insert () values (),(),(); how to get auto_increments properly?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In order to make this as "sql server independent" as possible, the first
thing you need to do is not use extended inserts as that is a MySQL
capability.  If you are insistent on using the extended inserts, then look
at the mysql_info() function.  That will return the number of rows inserted,
etc. on the last query.

-----Original Message-----
From: Rene Veerman [mailto:rene7705@xxxxxxxxx] 
Sent: Saturday, February 13, 2010 12:08 AM
To: php-general
Subject:  SQL insert () values (),(),(); how to get auto_increments
properly?

Hi.

I'm looking for the most efficient way to insert several records and
retrieve the auto_increment values for the inserted rows, while
avoiding crippling concurrency problems caused by multiple php threads
doing this on the same table at potentially the same time.

I'm using mysql atm, so i thought "stored procedures!"..
But alas, mysql docs are very basic.

I got the gist of how to setup a stored proc, but how to retrieve a
list of auto_increment ids still eludes me; last_insert_id() only
returns for the last row i believe.
So building an INSERT (...) VALUES (...),(...) at the php end, is
probably not the way to go then.

But the mysql docs don't show how to pass an array to a stored
procedure, so i can't just have the stored proc loop over an array,
insert per row, retrieve last_insert_id() into temp table, and return
the temp table contents for a list of auto_increment ids for inserted
rows.

Any clues are greatly appreciated..
I'm looking for the most sql server independent way to do this.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux