Exemplo n.º 1
0
 /**
  * Internal helper method for executing statments. Logs queries, and
  * stores statement object in ::_last_statment, accessible publicly
  * through ::get_last_statement()
  * @param string $query
  * @param array $parameters An array of parameters to be bound in to the query
  * @param string $connection_name Which connection to use
  * @return bool Response of PDOStatement::execute()
  */
 protected static function _execute($query, $parameters = array(), $connection_name = self::DEFAULT_CONNECTION)
 {
     self::_log_query($query, $parameters, $connection_name);
     $statement = self::$_db[$connection_name]->prepare($query);
     self::$_last_statement = $statement;
     return $statement->execute($parameters);
 }
Exemplo n.º 2
0
 /**
  * Internal helper method for executing statments. Logs queries, and
  * stores statement object in ::_last_statment, accessible publicly
  * through ::get_last_statement()
  * @param string $query
  * @param array $parameters An array of parameters to be bound in to the query
  * @param string $connection_name Which connection to use
  * @return bool Response of PDOStatement::execute()
  */
 protected static function _execute($query, $parameters = array(), $connection_name = self::DEFAULT_CONNECTION)
 {
     $statement = self::get_db($connection_name)->prepare($query);
     self::$_last_statement = $statement;
     $time = microtime(true);
     foreach ($parameters as $key => &$param) {
         if (is_null($param)) {
             $type = PDO::PARAM_NULL;
         } else {
             if (is_bool($param)) {
                 $type = PDO::PARAM_BOOL;
             } else {
                 if (is_int($param)) {
                     $type = PDO::PARAM_INT;
                 } else {
                     $type = PDO::PARAM_STR;
                 }
             }
         }
         $statement->bindParam(is_int($key) ? ++$key : $key, $param, $type);
     }
     $q = $statement->execute();
     self::_log_query($query, $parameters, $connection_name, microtime(true) - $time);
     return $q;
 }
Exemplo n.º 3
0
 /**
  * Internal helper method for executing statments. Logs queries, and
  * stores statement object in ::_last_statment, accessible publicly
  * through ::get_last_statement()
  * @param string $query
  * @param array $parameters An array of parameters to be bound in to the query
  * @param string $connection_name Which connection to use
  * @return bool Response of PDOStatement::execute()
  */
 protected static function _execute($query, $parameters = array(), $connection_name = self::DEFAULT_CONNECTION)
 {
     $statement = self::get_db($connection_name)->prepare($query);
     self::$_last_statement = $statement;
     $time = microtime(true);
     $count = count($parameters);
     for ($i = 0; $i < $count; $i++) {
         $type = PDO::PARAM_STR;
         if (is_null($parameters[$i])) {
             $type = PDO::PARAM_NULL;
         }
         if (is_bool($parameters[$i])) {
             $type = PDO::PARAM_BOOL;
         }
         if (is_int($parameters[$i])) {
             $type = PDO::PARAM_INT;
         }
         $statement->bindParam($i + 1, $parameters[$i], $type);
     }
     $q = $statement->execute();
     self::_log_query($query, $parameters, $connection_name, microtime(true) - $time);
     return $q;
 }