Zeile 72 | Zeile 72 |
---|
* @var resource */ public $current_link;
|
* @var resource */ public $current_link;
|
| /** * @var array */ public $connections = array();
|
/** * The database name.
| /** * The database name.
|
Zeile 175 | Zeile 180 |
---|
else { $connections = $config;
|
else { $connections = $config;
|
} }
| } }
|
$this->db_encoding = $config['encoding'];
| $this->db_encoding = $config['encoding'];
|
Zeile 186 | Zeile 191 |
---|
if(!isset($connections[$type]) || !is_array($connections[$type])) { break;
|
if(!isset($connections[$type]) || !is_array($connections[$type])) { break;
|
}
| }
|
if(array_key_exists('hostname', $connections[$type])) { $details = $connections[$type];
|
if(array_key_exists('hostname', $connections[$type])) { $details = $connections[$type];
|
unset($connections);
| unset($connections[$type]);
|
$connections[$type][] = $details;
|
$connections[$type][] = $details;
|
}
| }
|
// Shuffle the connections shuffle($connections[$type]);
| // Shuffle the connections shuffle($connections[$type]);
|
Zeile 205 | Zeile 210 |
---|
if(isset($single_connection['pconnect'])) { $connect_function = "mysql_pconnect";
|
if(isset($single_connection['pconnect'])) { $connect_function = "mysql_pconnect";
|
}
| }
|
$link = "{$type}_link";
|
$link = "{$type}_link";
|
|
|
get_execution_time();
$this->$link = @$connect_function($single_connection['hostname'], $single_connection['username'], $single_connection['password'], 1);
|
get_execution_time();
$this->$link = @$connect_function($single_connection['hostname'], $single_connection['username'], $single_connection['password'], 1);
|
|
|
$time_spent = get_execution_time(); $this->query_time += $time_spent;
// Successful connection? break down brother! if($this->$link)
|
$time_spent = get_execution_time(); $this->query_time += $time_spent;
// Successful connection? break down brother! if($this->$link)
|
{
| {
|
$this->connections[] = "[".strtoupper($type)."] {$single_connection['username']}@{$single_connection['hostname']} (Connected in ".format_time_duration($time_spent).")"; break;
|
$this->connections[] = "[".strtoupper($type)."] {$single_connection['username']}@{$single_connection['hostname']} (Connected in ".format_time_duration($time_spent).")"; break;
|
}
| }
|
else { $this->connections[] = "<span style=\"color: red\">[FAILED] [".strtoupper($type)."] {$single_connection['username']}@{$single_connection['hostname']}</span>";
|
else { $this->connections[] = "<span style=\"color: red\">[FAILED] [".strtoupper($type)."] {$single_connection['username']}@{$single_connection['hostname']}</span>";
|
} } }
| } } }
|
// No write server was specified (simple connection or just multiple servers) - mirror write link if(!array_key_exists('write', $connections)) {
| // No write server was specified (simple connection or just multiple servers) - mirror write link if(!array_key_exists('write', $connections)) {
|
Zeile 252 | Zeile 257 |
---|
if(!$this->select_db($config['database'])) { return -1;
|
if(!$this->select_db($config['database'])) { return -1;
|
}
$this->current_link = &$this->read_link;
| }
$this->current_link = &$this->read_link;
|
return $this->read_link; }
| return $this->read_link; }
|
Zeile 279 | Zeile 284 |
---|
else { $success = $read_success;
|
else { $success = $read_success;
|
}
| }
|
if($success && $this->db_encoding) {
| if($success && $this->db_encoding) {
|
Zeile 290 | Zeile 295 |
---|
else { $this->query("SET NAMES '{$this->db_encoding}'");
|
else { $this->query("SET NAMES '{$this->db_encoding}'");
|
}
| }
|
if($write_success && count($this->connections) > 1) { if(version_compare(PHP_VERSION, '5.2.3', '>=')) {
| if($write_success && count($this->connections) > 1) { if(version_compare(PHP_VERSION, '5.2.3', '>=')) {
|
Zeile 317 | Zeile 322 |
---|
function query($string, $hide_errors=0, $write_query=0) { global $mybb;
|
function query($string, $hide_errors=0, $write_query=0) { global $mybb;
|
|
|
get_execution_time();
// Only execute write queries on master database
| get_execution_time();
// Only execute write queries on master database
|
Zeile 330 | Zeile 335 |
---|
{ $this->current_link = &$this->read_link; $query = @mysql_query($string, $this->read_link);
|
{ $this->current_link = &$this->read_link; $query = @mysql_query($string, $this->read_link);
|
}
| }
|
if($this->error_number() && !$hide_errors) { $this->error($string);
| if($this->error_number() && !$hide_errors) { $this->error($string);
|
Zeile 433 | Zeile 438 |
---|
$this->explain .= "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n". "<tr>\n". "<td style=\"background-color: #ccc;\">{$debug_extra}<div><strong>#".$this->query_count." - Write Query</strong></div></td>\n".
|
$this->explain .= "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n". "<tr>\n". "<td style=\"background-color: #ccc;\">{$debug_extra}<div><strong>#".$this->query_count." - Write Query</strong></div></td>\n".
|
"</tr>\n".
| "</tr>\n".
|
"<tr style=\"background-color: #fefefe;\">\n". "<td><span style=\"font-family: Courier; font-size: 14px;\">".htmlspecialchars_uni($string)."</span></td>\n". "</tr>\n".
| "<tr style=\"background-color: #fefefe;\">\n". "<td><span style=\"font-family: Courier; font-size: 14px;\">".htmlspecialchars_uni($string)."</span></td>\n". "</tr>\n".
|
Zeile 446 | Zeile 451 |
---|
$this->querylist[$this->query_count]['query'] = $string; $this->querylist[$this->query_count]['time'] = $qtime;
|
$this->querylist[$this->query_count]['query'] = $string; $this->querylist[$this->query_count]['time'] = $qtime;
|
}
| }
|
/** * Return a result array for a query.
| /** * Return a result array for a query.
|
Zeile 485 | Zeile 490 |
---|
if($row === false) { $array = $this->fetch_array($query);
|
if($row === false) { $array = $this->fetch_array($query);
|
return $array[$field];
| if($array !== null) { return $array[$field]; } return null;
|
} else {
| } else {
|
Zeile 1042 | Zeile 1051 |
---|
*/ function escape_string_like($string) {
|
*/ function escape_string_like($string) {
|
return $this->escape_string(str_replace(array('%', '_') , array('\\%' , '\\_') , $string));
| return $this->escape_string(str_replace(array('\\', '%', '_') , array('\\\\', '\\%' , '\\_') , $string));
|
}
/**
| }
/**
|
Zeile 1412 | Zeile 1421 |
---|
$default = ''; }
|
$default = ''; }
|
return (bool)$this->write_query("ALTER TABLE {$this->table_prefix}{$table} MODIFY `{$column}` {$new_definition} {$not_null}");
| return (bool)$this->write_query("ALTER TABLE {$this->table_prefix}{$table} MODIFY `{$column}` {$new_definition} {$not_null} {$default}");
|
}
/**
| }
/**
|