mirror of
https://github.com/dg/dibi.git
synced 2025-08-04 05:07:36 +02:00
getInsertId() is be able to return negative ID's [Closes #336]
This commit is contained in:
@@ -315,7 +315,7 @@ class Connection implements IConnection
|
|||||||
$this->connect();
|
$this->connect();
|
||||||
}
|
}
|
||||||
$id = $this->driver->getInsertId($sequence);
|
$id = $this->driver->getInsertId($sequence);
|
||||||
if ($id < 1) {
|
if ($id === null) {
|
||||||
throw new Exception('Cannot retrieve last generated ID.');
|
throw new Exception('Cannot retrieve last generated ID.');
|
||||||
}
|
}
|
||||||
return $id;
|
return $id;
|
||||||
|
@@ -199,7 +199,7 @@ class MySqliDriver implements Dibi\Driver
|
|||||||
*/
|
*/
|
||||||
public function getInsertId(?string $sequence): ?int
|
public function getInsertId(?string $sequence): ?int
|
||||||
{
|
{
|
||||||
return $this->connection->insert_id;
|
return $this->connection->insert_id ?: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -139,7 +139,7 @@ class SqliteDriver implements Dibi\Driver
|
|||||||
*/
|
*/
|
||||||
public function getInsertId(?string $sequence): ?int
|
public function getInsertId(?string $sequence): ?int
|
||||||
{
|
{
|
||||||
return $this->connection->lastInsertRowID();
|
return $this->connection->lastInsertRowID() ?: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user