複数行の挿入を使用して、最後に挿入された ID を取得するにはどうすればよいですか? これが私のコードです:
$sql='INSERT INTO t (col1, col2, col3) VALUES (1, 2, 3), (4, 5, 6), (7, 8, 9)'; // example
$stmt = $contactsTable->getAdapter()->prepare($sql);
$stmt->execute();
$rowsAdded=$stmt->rowCount(); // mysql_affected_rows
$lastId=$stmt->lastInsertId();
echo '<br>Last ID: '.$lastId;
また、挿入の前に次の挿入 ID を取得する方法が ZF にありますか?
ありがとう