Ejemplo n.º 1
0
 /**
  * @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;
 }
Ejemplo n.º 2
0
 /**
  * Binds a PHP variable to a corresponding named or question mark placeholder in the
  * SQL statement that was use to prepare the statement.
  *
  * @param mixed $column Either the placeholder name or the 1-indexed placeholder index
  * @param mixed $variable The variable to bind
  * @param integer|null $type one of the  PDO::PARAM_* constants
  * @param integer|null $length max length when using an OUT bind
  * @return boolean
  */
 public function bindParam($column, &$variable, $type = null, $length = null)
 {
     return $this->statement->bindParam($column, $variable, $type, $length);
 }
Ejemplo n.º 3
0
 /**
  * Binds a parameter to a value by reference.
  *
  * Binding a parameter by reference does not support DBAL mapping types.
  *
  * @param string       $name   The name or position of the parameter.
  * @param mixed        $var    The reference to the variable to bind.
  * @param integer      $type   The PDO binding type.
  * @param integer|null $length Must be specified when using an OUT bind
  *                             so that PHP allocates enough memory to hold the returned value.
  *
  * @return boolean TRUE on success, FALSE on failure.
  */
 public function bindParam($name, &$var, $type = PDO::PARAM_STR, $length = null)
 {
     return $this->stmt->bindParam($name, $var, $type, $length);
 }
Ejemplo n.º 4
0
 public function bindParam($column, &$variable, $type = null)
 {
     return $this->stmt->bindParam($column, $variable, $type);
 }
Ejemplo n.º 5
0
 /**
  * Binds a parameter to a value by reference.
  *
  * Binding a parameter by reference does not support DBAL mapping types.
  *
  * @param string       $name   The name or position of the parameter.
  * @param mixed        $var    The reference to the variable to bind.
  * @param integer      $type   The PDO binding type.
  * @param integer|null $length Must be specified when using an OUT bind
  *                             so that PHP allocates enough memory to hold the returned value.
  *
  * @return boolean TRUE on success, FALSE on failure.
  */
 public function bindParam($name, &$var, $type = PDO::PARAM_STR, $length = null)
 {
     $this->params[$name] = $var;
     $this->types[$name] = $type;
     return $this->stmt->bindParam($name, $var, $type, $length);
 }