function query($sql, $type = '') { global $debug, $discuz_starttime, $sqldebug, $sqlspenttimes; if (defined('SYS_DEBUG') && SYS_DEBUG) { @(include_once DISCUZ_ROOT . './include/debug.func.php'); sqldebug($sql); } $func = $type == 'UNBUFFERED' && @function_exists('mysql_unbuffered_query') ? 'mysql_unbuffered_query' : 'mysql_query'; if (!($query = $func($sql, $this->link))) { if (in_array($this->errno(), array(2006, 2013)) && substr($type, 0, 5) != 'RETRY') { $this->close(); require DISCUZ_ROOT . './config.inc.php'; $this->connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect, true, $dbcharset); $this->query($sql, 'RETRY' . $type); } elseif ($type != 'SILENT' && substr($type, 5) != 'SILENT') { $this->halt('MySQL Query Error', $sql); } } $this->querynum++; return $query; }
function query($sql, $type = '') { global $debug, $discuz_starttime, $sqldebug, $sqlspenttimes; if (defined('SYS_DEBUG') && SYS_DEBUG) { @(include_once DISCUZ_ROOT . './include/debug.func.php'); sqldebug($sql); } $func = $type == 'UNBUFFERED' && @function_exists('mysql_unbuffered_query') ? 'mysql_unbuffered_query' : 'mysqli_query'; if (!($query = $func($this->link, $sql))) { if (in_array($this->errno(), array(2006, 2013)) && substr($type, 0, 5) != 'RETRY') { $this->close(); $db_config = C("DB_CONFIG"); $this->connect($db_config["master1"][0], $db_config["master1"][1], $db_config["master1"][2], $db_config["master1"][4]); return $this->query($sql, 'RETRY' . $type); } elseif ($type != 'SILENT' && substr($type, 5) != 'SILENT') { $this->halt('MySQL Query Error', $sql); } } $this->querynum++; return $query; }