Exemplo n.º 1
0
 /**
  * Query without returning an empty array like our function query(). http://php.net/manual/en/pdo.query.php
  *
  * @param string $query  The query to run.
  * @param bool   $ignore Ignore errors, do not log them?
  *
  * @return bool|\PDOStatement
  */
 public function queryDirect($query, $ignore = false)
 {
     if (empty($query)) {
         return false;
     }
     if (NN_QUERY_STRIP_WHITESPACE) {
         $query = Utility::collapseWhiteSpace($query);
     }
     try {
         $result = $this->pdo->query($query);
     } catch (\PDOException $e) {
         // Check if we lost connection to MySQL.
         if ($this->_checkGoneAway($e->getMessage()) !== false) {
             // Reconnect to MySQL.
             if ($this->_reconnect() === true) {
                 // If we reconnected, retry the query.
                 $result = $this->queryDirect($query);
             } else {
                 // If we are not reconnected, return false.
                 $result = false;
             }
         } else {
             if ($ignore === false) {
                 $this->echoError($e->getMessage(), 'queryDirect', 4, false);
                 if ($this->_debug) {
                     $this->debugging->log(get_class(), __FUNCTION__, $query, \Logger::LOG_SQL);
                 }
             }
             $result = false;
         }
     }
     return $result;
 }