/** * Checks if the query is empty. Cleans the query of whitespace is needed. * * @param reference string $query * * @return bool */ private function parseQuery(&$query) { if (empty($query)) { return false; } if (nZEDb_QUERY_STRIP_WHITESPACE) { $query = Utility::collapseWhiteSpace($query); } return true; }
/** * 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 (nZEDb_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('\\nzedb\\db\\DB', "queryDirect", $query, \Logger::LOG_SQL); } } $result = false; } } return $result; }