/** * Execute a "select"-query. * * @param string $table * @param string|array $where * * @return false|Result false on error */ public function select($table, $where = '1=1') { if ($table === '') { $this->_debug->displayError('invalid table name'); return false; } if (is_string($where)) { $WHERE = $this->escape($where, false); } elseif (is_array($where)) { $WHERE = $this->_parseArrayPair($where, 'AND'); } else { $WHERE = ''; } $sql = 'SELECT * FROM ' . $this->quote_string($table) . " WHERE ({$WHERE});"; return $this->query($sql); }
/** * Error-handling for the sql-query. * * @param string $errorMsg * @param string $sql * * @throws \Exception * * @return bool */ private function queryErrorHandling($errorMsg, $sql) { if ($errorMsg === 'DB server has gone away' || $errorMsg === 'MySQL server has gone away') { static $reconnectCounter; // exit if we have more then 3 "DB server has gone away"-errors if ($reconnectCounter > 3) { $this->_debug->mailToAdmin('SQL-Fatal-Error', $errorMsg . ":\n<br />" . $sql, 5); throw new \Exception($errorMsg); } else { $this->_debug->mailToAdmin('SQL-Error', $errorMsg . ":\n<br />" . $sql); // reconnect $reconnectCounter++; $this->_db->reconnect(true); // re-run the current query return $this->execute(); } } else { $this->_debug->mailToAdmin('SQL-Warning', $errorMsg . ":\n<br />" . $sql); // this query returned an error, we must display it (only for dev) !!! $this->_debug->displayError($errorMsg . ' | ' . $sql); } return false; }