PDO Get multiple insert identifiers

Executing the following query using PDO (actually, I am using prepared statements, but with the same problem)

INSERT INTO MyTable(MyField) VALUES('Row1'), ('Row2')

How to get identifiers for records related to Row1and Row2?

$db->lastInsertId() literally returns the last single identifier.

Is it enough to take this last Id, subtract the number of records and assume that the range covers all my records? there may be spaces / jumps. Is this query guaranteed to be atomic?

+5
source share

All Articles