/**
  * @param string $sql     Consulta SQL a la base de datos
  * @param array $criteria Criterios de la consulta SQL adoptados en el WHERE
  *
  * @return Statement Retorna el objeto de DoctrineORM Statement
  * @throws DBALException Error de DoctrineORM
  * @throws Exception Error en el SQL
  */
 protected function _query($sql = "", array $criteria = array())
 {
     try {
         // Preparar el SQL
         $this->_stmt = $this->_connection->prepare($sql);
         // Agregar los parametros
         foreach ($criteria as $param => $value) {
             if (is_integer($param)) {
                 $this->_stmt->bindValue($param + 1, $value);
             }
             if (is_string($param)) {
                 $this->_stmt->bindParam($param, $value);
             }
         }
         // Ejecutar el SQL
         $this->_stmt->execute();
     } catch (DBALException $dbalException) {
         #throw $dbalException;
     }
     if (in_array($this->_stmt->errorCode(), array_keys($this->_errors))) {
         throw new Exception($this->_errors[$this->_stmt->errorCode()] . " SQL: {$sql}");
     }
     return $this->_stmt;
 }
 public function errorCode()
 {
     return $this->stmt->errorCode();
 }
Exemple #3
0
 public function errorCode()
 {
     return $this->wrapped->errorCode();
 }
Exemple #4
0
 /**
  * @brief Writes debug output including additional SQL error info to the	ownCloud log.
  *
  * @param string $output The string appended to ownCloud log.
  * @param \Doctrine\DBAL\Driver\Statement $query The query whose information
  *	will be added to the debug output.
  * @param int $level Log level of debug output. Default is \OCP\Util::ERROR.
  */
 public static function writeLogDbError($output, $query, $level = \OCP\Util::ERROR)
 {
     $output = $output . " SQLSTATE: " . $query->errorCode() . ". Error info: " . var_export($query->errorInfo(), true);
     self::writeLog($output, $level);
 }