我正在使用Postgresql,當我想使用PDO檢索最新插入ID時,出現問題。這裏是我的代碼:lastInsertId在Postgresql中不起作用
$db->lastInsertId('columnName');
錯誤消息說
SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "columnName" does not exist
我想我對PHP手冊中指出,「序列對象」的一些誤解。
Note:
Returns the ID of the last inserted row, or the last value from a sequence object,
depending on the underlying driver. For example, PDO_PGSQL() requires you to specify the
name of a sequence object for the name parameter.
當前,「columnName」是該自動遞增屬性的字符串。任何人都可以指出我出錯的地方嗎?謝謝。
[在PDO準備插入後獲取最後一個插入id]的可能重複(http://stackoverflow.com/questions/5057954/get-last-insert-id-after-a-prepared-insert-with-pdo ) –