| @@ 42-55 (lines=14) @@ | ||
| 39 | * @return array |
|
| 40 | * @throws Exception |
|
| 41 | */ |
|
| 42 | public function fetchAll($statement) |
|
| 43 | { |
|
| 44 | if (!$statement instanceof \PDOStatement) { |
|
| 45 | $this->log(Logger::ERROR, 'Statement not in right format', array('statement' => $statement)); |
|
| 46 | throw new Exception('Statement not in right format'); |
|
| 47 | } |
|
| 48 | ||
| 49 | try { |
|
| 50 | return $statement->fetchAll($this->getFetchMode()); |
|
| 51 | } catch (\PDOException $e) { |
|
| 52 | $this->log(Logger::ERROR, $e->getMessage(), array('error' => $e)); |
|
| 53 | throw new Exception($e->getMessage(), (int)$e->getCode(), $e); |
|
| 54 | } |
|
| 55 | } |
|
| 56 | ||
| 57 | /** |
|
| 58 | * Begin a transaction |
|
| @@ 198-211 (lines=14) @@ | ||
| 195 | * @return int |
|
| 196 | * @throws Exception |
|
| 197 | */ |
|
| 198 | public function count($statement) |
|
| 199 | { |
|
| 200 | if (!$statement instanceof \PDOStatement) { |
|
| 201 | $this->log(Logger::ERROR, 'Statement not in right format', array('statement' => $statement)); |
|
| 202 | throw new Exception('Statement not in right format'); |
|
| 203 | } |
|
| 204 | ||
| 205 | try { |
|
| 206 | return $statement->rowCount(); |
|
| 207 | } catch (\PDOException $e) { |
|
| 208 | $this->log(Logger::ERROR, $e->getMessage(), array('error' => $e)); |
|
| 209 | throw new Exception($e->getMessage(), (int)$e->getCode(), $e); |
|
| 210 | } |
|
| 211 | } |
|
| 212 | } |
|
| 213 | ||