Пример #1
0
 /**
  * Wrapper for the execute function to calculate time spent
  * and log the query afterwards.
  *
  * @param array $params list of values to be bound to query
  * @return bool true on success, false otherwise
  */
 public function execute($params = null)
 {
     $t = microtime(true);
     $result = parent::execute($params);
     $query = new LoggedQuery();
     $query->took = round((microtime(true) - $t) * 1000, 0);
     $query->numRows = $this->rowCount();
     $query->params = $params ?: $this->_compiledParams;
     $query->query = $this->queryString;
     $this->logger()->log($query);
     return $result;
 }
Пример #2
0
 /**
  * Wrapper for the execute function to calculate time spent
  * and log the query afterwards.
  *
  * @param array|null $params List of values to be bound to query
  * @return bool True on success, false otherwise
  * @throws \Exception Re-throws any exception raised during query execution.
  */
 public function execute($params = null)
 {
     $t = microtime(true);
     $query = new LoggedQuery();
     try {
         $result = parent::execute($params);
     } catch (Exception $e) {
         $e->queryString = $this->queryString;
         $query->error = $e;
         $this->_log($query, $params, $t);
         throw $e;
     }
     $query->numRows = $this->rowCount();
     $this->_log($query, $params, $t);
     return $result;
 }