/**
  * @test
  */
 public function shouldThrowConnectionExceptionFromForPostgres()
 {
     //given
     Config::overrideProperty('sql_dialect')->with('\\Ouzo\\Db\\Dialect\\PostgresDialect');
     Mock::when($this->pdoMock)->errorInfo()->thenReturn(array('57P01', 7, 'Execution error'));
     $executor = StatementExecutor::prepare($this->dbMock, 'SELECT 1', array(), array());
     //when
     CatchException::when($executor)->execute();
     //then
     CatchException::assertThat()->isInstanceOf('\\Ouzo\\DbConnectionException');
     Config::revertProperty('sql_dialect');
 }
Exemple #2
0
 /**
  * Returns number of affected rows
  * @param string $query
  * @param array $params
  * @param array $options
  * @return int
  */
 public function execute($query, $params = array(), $options = array())
 {
     return StatementExecutor::prepare($this->_dbHandle, $query, $params, $options)->execute();
 }
Exemple #3
0
 private function _fetch($function)
 {
     $statement = StatementExecutor::prepare($this->_db->_dbHandle, $this->_sql, $this->_boundValues, $this->_query->options);
     return $statement->executeAndFetch($function, $this->_fetchStyle);
 }