Ejemplo n.º 1
0
 /**
  * Execute SQL query
  *
  * @param string $sql
  * @param bool $unbuffer
  * @throws waDbException
  * @return resource
  */
 private function run($sql, $unbuffer = false)
 {
     $sql = trim($sql);
     $result = $this->adapter->query($sql);
     if (!$result) {
         $error = "Query Error\nQuery: " . $sql . "\nError: " . $this->adapter->errorCode() . "\nMessage: " . $this->adapter->error();
         $trace = debug_backtrace();
         $stack = "";
         foreach ($trace as $i => $row) {
             $stack .= $i . ". " . $row['file'] . ":" . $row['line'] . "\n" . (isset($row['class']) ? $row['class'] : '') . (isset($row['type']) ? $row['type'] : '') . $row['function'] . "()\n";
         }
         waLog::log($error . "\nStack:\n" . $stack, 'db.log');
         throw new waDbException($error, $this->adapter->errorCode());
     }
     return $result;
 }