Closed takpunya closed 3 years ago
MySQL: "With no argument, LAST_INSERT_ID() returns a BIGINT UNSIGNED (64-bit) value representing the first automatically generated value successfully inserted for an AUTO_INCREMENT column as a result of the most recently executed INSERT statement."
MariaDB: "LAST_INSERT_ID() (no arguments) returns the first automatically generated value successfully inserted for an AUTO_INCREMENT column as a result of the most recently executed INSERT statement."
This is clearly not what lastInsertId's own documentation states. Hopefully this will save someone from debugging the cause of id mismatch.
Describe the bug
I have primary key with UUID and datatype is binary(16).
Tryin to get last primary key after insert() but always returning to 0
$database->id();
when perform last query, it also showin 0 to primary keys value.
$database->last();
Is it a bug or there something that i missed?
I just see id() is using using lastinsertedid:
return $this->pdo->lastInsertId();
http://php.net/manual/en/pdo.lastinsertid.php
So it temporary solved by changed primary key to auto increment, but not working if my primay key only uuid.
Information
Detail Code
Expected output $last_uuid return to row id but currently always return to 0