diff --git a/src/Connection.php b/src/Connection.php index 7f7ca11..1966c8e 100644 --- a/src/Connection.php +++ b/src/Connection.php @@ -57,6 +57,11 @@ public function getPdo() : PDO return $this->pdo; } + public function getLastInsertId(string $name = null) : string + { + return $this->pdo->lastInsertId($name); + } + public function perform( string $statement, array $values = [] diff --git a/tests/ConnectionTest.php b/tests/ConnectionTest.php index e645ddd..4da999c 100644 --- a/tests/ConnectionTest.php +++ b/tests/ConnectionTest.php @@ -65,6 +65,12 @@ public function testGetPdo() $this->assertSame($this->pdo, $this->connection->getPdo()); } + public function testGetLastInsertId() + { + $actual = $this->connection->getLastInsertId(); + $this->assertEquals(10, $actual); + } + public function testPerform() { $stm = $this->connection->perform("SELECT * FROM pdotest WHERE id = ?", [1]);