Skip to content

Commit

Permalink
add Connection::getLastInsertId()
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul M. Jones committed Apr 4, 2018
1 parent 5c89694 commit 8a63019
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
6 changes: 6 additions & 0 deletions tests/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down

0 comments on commit 8a63019

Please sign in to comment.