prepare() public static method

public static prepare ( $dbHandle, $sql, $boundValues, $options )
Esempio n. 1
0
 /**
  * @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');
 }
Esempio n. 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();
 }
Esempio n. 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);
 }