SQLite3::lastInsertRowID

(PHP 5 >= 5.3.0, PHP 7, PHP 8)

SQLite3::lastInsertRowID直近の INSERT 文でデータベースに追加された行の ID を返す

説明

public SQLite3::lastInsertRowID(): int

直近の INSERT 文でデータベースに追加された行の ID を返します。

パラメータ

この関数にはパラメータはありません。

戻り値

直近の INSERT 文でデータベースに追加された行の ID を返します。 現在の接続で、rowid テーブルへの INSERT が成功しなかったことがある場合は、 SQLite3::lastInsertRowID()0 を返します。

add a note

User Contributed Notes 1 note

up
22
alexofen at KEINSpamgmail dot com
10 years ago
lastInsertRowID is relative to the database connection. Hence if there are two instances of a php script (with distinct $db connections) there is no risk that the RowID of the one instance will effect the result of the other instance.I mention this point here as it was not clear from the documentation, at least not very clear to me and hence I hope it might help others.
To Top