Exemplo n.º 1
0
 /**
  * Executes statement.
  * @param  array
  * @return self
  */
 public function execute($params = array())
 {
     static $types = array('boolean' => PDO::PARAM_BOOL, 'integer' => PDO::PARAM_INT, 'resource' => PDO::PARAM_LOB, 'NULL' => PDO::PARAM_NULL);
     foreach ($params as $param => $value) {
         $type = gettype($value);
         $this->bindValue(is_int($param) ? $param + 1 : $param, $value, isset($types[$type]) ? $types[$type] : PDO::PARAM_STR);
     }
     $time = microtime(TRUE);
     try {
         parent::execute();
     } catch (PDOException $e) {
         $e->queryString = $this->queryString;
         $this->connection->onError($this, $params, $e);
         throw $e;
     }
     $this->time = microtime(TRUE) - $time;
     $this->connection->onQuery($this, $params);
     // $this->connection->onQuery() in PHP 5.3
     return $this;
 }