I’m using MySQL 5.5 with PHP 5.4. I’m performing a bulk insert and need to capture all of the newly inserted ID’s. This is my code:
$db->query("INSERT INTO commodity (analysis_id, commodity_description, a_units,
a_average_yield, a_average_price) SELECT $analysis_id, commodity_description,
a_units, a_average_yield, a_average_price FROM commodity WHERE analysis_id =
$import_analysis_id");
Is there a way to retrieve all of the new ID’s of the inserted rows? Using $db->insert_id only returns a single ID. I would hate to have to use a PHP loop and execute several queries, but I will if I have to. Thanks!
I guess I was over thinking this. Since I’m inserting the analysis_id (eg, case number, customer number, etc.), I decided to just run a query after this one that would pull all of the ID’s for the inserted analysis_id. This solved my problem.