Tôi đang sử dụng Postgresql, khi tôi muốn sử dụng PDO để truy xuất ID chèn mới nhất, tôi gặp sự cố. Đây là mã của tôi:lastInsertId không hoạt động trong Postgresql
$db->lastInsertId('columnName');
Các thông báo lỗi nói
SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "columnName" does not exist
Tôi đoán tôi có một số hiểu lầm về "đối tượng chuỗi" đã nêu trong Hướng dẫn sử dụng 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.
Hiện tại, "columnName" là chuỗi thuộc tính tự động tăng. Bất cứ ai có thể chỉ ra nơi tôi đã đi sai? Cảm ơn.
Bản sao có thể có của [Nhận id chèn cuối cùng sau khi chèn được chuẩn bị với PDO] (http://stackoverflow.com/questions/5057954/get-last-insert-id-after-a-prepared-insert-with-pdo) –