|
@@ 142-155 (lines=14) @@
|
| 139 |
|
* @throws NoResultException |
| 140 |
|
* @throws NonUniqueResultException |
| 141 |
|
*/ |
| 142 |
|
public function getSingleRowResult() |
| 143 |
|
{ |
| 144 |
|
$row = $this->statement->fetch(\PDO::FETCH_BOTH); |
| 145 |
|
|
| 146 |
|
if (false === $row) { |
| 147 |
|
throw new NoResultException('Expected on result for given query.'); |
| 148 |
|
} |
| 149 |
|
|
| 150 |
|
if (false !== $this->statement->fetch()) { |
| 151 |
|
throw new NonUniqueResultException('Expected only ine result for given query.'); |
| 152 |
|
} |
| 153 |
|
|
| 154 |
|
return $row; |
| 155 |
|
} |
| 156 |
|
|
| 157 |
|
/** |
| 158 |
|
* Get single (first) row result from result set or default value if result set is empty. |
|
@@ 49-62 (lines=14) @@
|
| 46 |
|
* @throws NoResultException |
| 47 |
|
* @throws NonUniqueResultException |
| 48 |
|
*/ |
| 49 |
|
public function getSingleScalarResult() |
| 50 |
|
{ |
| 51 |
|
$scalar = $this->statement->fetchColumn(0); |
| 52 |
|
|
| 53 |
|
if (false === $scalar) { |
| 54 |
|
throw new NoResultException('Expected on result for given query.'); |
| 55 |
|
} |
| 56 |
|
|
| 57 |
|
if (false !== $this->statement->fetch()) { |
| 58 |
|
throw new NonUniqueResultException('Expected only one result for given query.'); |
| 59 |
|
} |
| 60 |
|
|
| 61 |
|
return $scalar; |
| 62 |
|
} |
| 63 |
|
|
| 64 |
|
/** |
| 65 |
|
* Get single scalar result or default value if there are no results of executed |