Skip to content

Commit

Permalink
Merge pull request #129 from DQNEO/fix-phpdoc
Browse files Browse the repository at this point in the history
fetchObject and fetchOne may return false
  • Loading branch information
Paul M. Jones authored Jun 24, 2016
2 parents 842ea73 + d202410 commit 11bbe6f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/ExtendedPdo.php
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ public function fetchCol(
*
* @param array $ctor_args Arguments to pass to the object constructor.
*
* @return object
* @return object|false
*
*/
public function fetchObject(
Expand Down Expand Up @@ -537,7 +537,7 @@ public function fetchObjects(
*
* @param array $values Values to bind to the query.
*
* @return array
* @return array|false
*
*/
public function fetchOne($statement, array $values = array())
Expand Down
4 changes: 2 additions & 2 deletions src/ExtendedPdoInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function fetchCol($statement, array $values = array(), $callable = null);
*
* @param array $ctor_args Arguments to pass to the object constructor.
*
* @return object
* @return object|false
*
*/
public function fetchObject(
Expand Down Expand Up @@ -163,7 +163,7 @@ public function fetchObjects(
*
* @param array $values Values to bind to the query.
*
* @return array
* @return array|false
*
*/
public function fetchOne($statement, array $values = array());
Expand Down
14 changes: 14 additions & 0 deletions tests/AbstractExtendedPdoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,13 @@ public function testFetchObject()
$this->assertSame('Anna', $actual->name);
}

public function testFetchObjectReturningFalse()
{
$stm = "SELECT id, name FROM pdotest WHERE id = ?";
$actual = $this->pdo->fetchObject($stm, array(-1));
$this->assertFalse($actual);
}

public function testFetchObject_withCtorArgs()
{
$stm = "SELECT id, name FROM pdotest WHERE id = ?";
Expand Down Expand Up @@ -419,6 +426,13 @@ public function testFetchOne()
$this->assertEquals($expect, $actual);
}

public function testFetchOneReturningFalse()
{
$stm = "SELECT id, name FROM pdotest WHERE id = -1";
$actual = $this->pdo->fetchOne($stm);
$this->assertFalse($actual);
}

public function testGroupSingleColumn()
{
$stm = "SELECT id, name FROM pdotest WHERE id = 1";
Expand Down

0 comments on commit 11bbe6f

Please sign in to comment.