Hello.
Tell me, is it possible to get the identifiers of the inserted rows (preferably using PHP) if they are inserted without locking the table (myisam)?
INSERT INTO table (row1, row1) VALUES(2, 3), (5, 2), (7, 9);
If I understood correctly, you need mysql_insert_id
, for PDO lastInsertId();
If it is necessary for multiple insertion, then there are no embedded solutions (at least I don’t know), but try this
mysql_insert_id()
will issue the first id
mysql_insert_id() + 2
- will give the last identifier - this is exactly in your case. - that is, we add (N-1), where N is the number of inserted data.
A little googling that's what I found
/** * Возвращает список всех вставленных ID с помощью multiInsert() **/ function get_all_insert_id($countLines) { $arID = array(); for ($i = mysql_insert_id(); $i <= (mysql_insert_id() + $countLines); $i++) { $arID[] = $i; } return $arID; }
Probably pure PHP means impossible. Send a query of the type: SELECT id FROM table ORDER BY id DESC LIMIT 3
Source: https://ru.stackoverflow.com/questions/293698/
All Articles