protected function runQuery( $sql, $bindings, $options = array() )
{
$this->connect();
if ( $this->loggingEnabled && $this->logger ) {
$this->logger->log( $sql, $bindings );
}
try {
if ( strpos( 'pgsql', $this->dsn ) === 0 ) {
//one line because unable to test this otherwise (coverage trick).
if ( defined( '\PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT' ) ) { $statement = $this->pdo->prepare( $sql, array( \PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT => TRUE ) ); } else { $statement = $this->pdo->prepare( $sql ); }
} else {
$statement = $this->pdo->prepare( $sql );
}
$this->bindParams( $statement, $bindings );
$statement->execute();
$this->queryCounter ++;
$this->affectedRows = $statement->rowCount();
if ( $statement->columnCount() ) {
$fetchStyle = ( isset( $options['fetchStyle'] ) ) ? $options['fetchStyle'] : NULL;
if ( isset( $options['noFetch'] ) && $options['noFetch'] ) {
$this->resultArray = array();
return $statement;
}
$this->resultArray = $statement->fetchAll( $fetchStyle );
if ( $this->loggingEnabled && $this->logger ) {
$this->logger->log( 'resultset: ' . count( $this->resultArray ) . ' rows' );
}
} else {
$this->resultArray = array();
}
} catch ( \PDOException $e ) {
//Unfortunately the code field is supposed to be int by default (php)
//So we need a property to convey the SQL State code.
$err = $e->getMessage();
if ( $this->loggingEnabled && $this->logger ) $this->logger->log( 'An error occurred: ' . $err );
$exception = new SQL( $err, 0, $e ); // это 810 строка я так понимаю в ней какая-то проблема, но я хз какая
$exception->setSQLState( $e->getCode() );
$exception->setDriverDetails( $e->errorInfo );
throw $exception;
}
}