Zeile 6 | Zeile 6 |
---|
* Website: http://www.mybboard.net * License: http://www.mybboard.net/about/license *
|
* Website: http://www.mybboard.net * License: http://www.mybboard.net/about/license *
|
* $Id: db_mysql.php 4067 2008-08-04 03:59:08Z Tikitiki $
| * $Id: db_mysql.php 4261 2008-11-03 01:11:33Z Tikitiki $
|
*/
class DB_MySQL
| */
class DB_MySQL
|
Zeile 143 | Zeile 143 |
---|
{ $connections['read'][] = $config; }
|
{ $connections['read'][] = $config; }
|
| else
|
// Connecting to more than one server { // Specified multiple servers, but no specific read/write servers if(!array_key_exists('read', $config)) { foreach($config as $key => $settings)
|
// Connecting to more than one server { // Specified multiple servers, but no specific read/write servers if(!array_key_exists('read', $config)) { foreach($config as $key => $settings)
|
{
| {
|
if(is_int($key)) $connections['read'][] = $settings; } } // Specified both read & write servers else
|
if(is_int($key)) $connections['read'][] = $settings; } } // Specified both read & write servers else
|
{
| {
|
$connections = $config; } }
$this->db_encoding = $config['encoding'];
|
$connections = $config; } }
$this->db_encoding = $config['encoding'];
|
|
|
// Actually connect to the specified servers foreach(array('read', 'write') as $type) {
| // Actually connect to the specified servers foreach(array('read', 'write') as $type) {
|
Zeile 192 | Zeile 193 |
---|
$link = $type."_link";
$this->get_execution_time();
|
$link = $type."_link";
$this->get_execution_time();
|
|
|
$this->$link = @$connect_function($single_connection['hostname'], $single_connection['username'], $single_connection['password'], 1);
$time_spent = $this->get_execution_time(); $this->query_time += $time_spent;
|
$this->$link = @$connect_function($single_connection['hostname'], $single_connection['username'], $single_connection['password'], 1);
$time_spent = $this->get_execution_time(); $this->query_time += $time_spent;
|
|
|
// Successful connection? break down brother! if($this->$link) {
| // Successful connection? break down brother! if($this->$link) {
|
Zeile 209 | Zeile 210 |
---|
$this->connections[] = "<span style=\"color: red\">[FAILED] [".strtoupper($type)."] {$single_connection['username']}@{$single_connection['hostname']}</span>"; } }
|
$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)) { $this->write_link = &$this->read_link;
|
// No write server was specified (simple connection or just multiple servers) - mirror write link if(!array_key_exists('write', $connections)) { $this->write_link = &$this->read_link;
|
}
| }
|
// Have no read connection? if(!$this->read_link)
|
// Have no read connection? if(!$this->read_link)
|
{
| {
|
$this->error("[READ] Unable to connect to MySQL server"); } // No write? else if(!$this->write_link)
|
$this->error("[READ] Unable to connect to MySQL server"); } // No write? else if(!$this->write_link)
|
{
| {
|
$this->error("[WRITE] Unable to connect to MySQL server");
|
$this->error("[WRITE] Unable to connect to MySQL server");
|
}
| }
|
// Select databases
|
// Select databases
|
$this->select_db($config['database']);
| if(!$this->select_db($config['database'])) { return false; }
|
$this->current_link = &$this->read_link; return $this->read_link;
| $this->current_link = &$this->read_link; return $this->read_link;
|
Zeile 293 | Zeile 297 |
---|
{ $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) {
| if($this->error_number() && !$hide_errors) {
|
Zeile 443 | Zeile 447 |
---|
function data_seek($query, $row) { return mysql_data_seek($query, $row);
|
function data_seek($query, $row) { return mysql_data_seek($query, $row);
|
}
| }
|
/** * Return the number of rows resulting from a query.
| /** * Return the number of rows resulting from a query.
|
Zeile 454 | Zeile 458 |
---|
function num_rows($query) { return mysql_num_rows($query);
|
function num_rows($query) { return mysql_num_rows($query);
|
}
| }
|
/** * Return the last id number of inserted data. * * @return int The id number.
|
/** * Return the last id number of inserted data. * * @return int The id number.
|
*/
| */
|
function insert_id() { return mysql_insert_id($this->current_link);
|
function insert_id() { return mysql_insert_id($this->current_link);
|
}
| }
|
/** * Close the connection with the DBMS. * */ function close()
|
/** * Close the connection with the DBMS. * */ function close()
|
{
| {
|
@mysql_close($this->read_link); if($this->write_link) {
| @mysql_close($this->read_link); if($this->write_link) {
|
Zeile 489 | Zeile 493 |
---|
if($this->current_link) { return @mysql_errno($this->current_link);
|
if($this->current_link) { return @mysql_errno($this->current_link);
|
} else { return @mysql_errno(); }
| } else { return @mysql_errno(); }
|
}
/** * Return an error string. * * @return string The explanation for the current error.
|
}
/** * Return an error string. * * @return string The explanation for the current error.
|
*/
| */
|
function error_string() { if($this->current_link) { return @mysql_error($this->current_link);
|
function error_string() { if($this->current_link) { return @mysql_error($this->current_link);
|
}
| }
|
else { return @mysql_error();
| else { return @mysql_error();
|
Zeile 543 | Zeile 547 |
---|
{ trigger_error("<strong>[SQL] [".$this->error_number()."] ".$this->error_string()."</strong><br />{$string}", E_USER_ERROR); }
|
{ trigger_error("<strong>[SQL] [".$this->error_number()."] ".$this->error_string()."</strong><br />{$string}", E_USER_ERROR); }
|
| } else { return false;
|
} }
| } }
|
Zeile 1138 | Zeile 1146 |
---|
*/ function fetch_db_charsets() {
|
*/ function fetch_db_charsets() {
|
if($this_link && $this->get_version() < 4.1)
| if($this->link && version_compare($this->get_version(), "4.1", "<"))
|
{ return false; }
| { return false; }
|