Skip to content

Commit cb850fa

Browse files
committed
Connection::getInsertId() is normalized to string
1 parent 4b072ec commit cb850fa

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/Database/Connection.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ public function getSupplementalDriver()
124124
public function getInsertId($name = NULL)
125125
{
126126
try {
127-
return $this->getPdo()->lastInsertId($name);
127+
$res = $this->getPdo()->lastInsertId($name);
128+
return $res === FALSE ? '0' : $res;
128129
} catch (PDOException $e) {
129130
throw $this->driver->convertException($e);
130131
}

tests/Database/Connection.getInsertId().postgre.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ $connection->query('
1919
');
2020

2121
$connection->query('INSERT INTO primarykey (prim) VALUES (5)');
22-
Assert::equal(PHP_VERSION_ID < 70011 ? FALSE : '0', $connection->getInsertId());
22+
Assert::equal('0', $connection->getInsertId());
2323

2424
$connection->query('INSERT INTO primarykey (prim) VALUES (6)');
25-
Assert::equal(PHP_VERSION_ID < 70011 ? FALSE : '0', $connection->getInsertId());
25+
Assert::equal('0', $connection->getInsertId());
2626

2727

2828
$connection->query('

0 commit comments

Comments
 (0)