Zeile 72 | Zeile 72 |
---|
* @var resource */ public $current_link;
|
* @var resource */ public $current_link;
|
| /** * The database name. * * @var string */ public $database;
|
/** * Explanation of a query.
| /** * Explanation of a query.
|
Zeile 82 | Zeile 89 |
---|
/** * The current version of MySQL.
|
/** * The current version of MySQL.
|
* * @var string
| * * @var string
|
*/ public $version;
| */ public $version;
|
Zeile 100 | Zeile 107 |
---|
* @var string */ public $table_prefix;
|
* @var string */ public $table_prefix;
|
/**
| /**
|
* The extension used to run the SQL database * * @var string
| * The extension used to run the SQL database * * @var string
|
Zeile 110 | Zeile 117 |
---|
/** * Weather or not this engine can use the search functionality
|
/** * Weather or not this engine can use the search functionality
|
*
| *
|
* @var boolean */ public $can_search = true;
| * @var boolean */ public $can_search = true;
|
Zeile 128 | Zeile 135 |
---|
* @var float */ public $query_time = 0;
|
* @var float */ public $query_time = 0;
|
/**
| /**
|
* Stores previous run query type: 1 => write; 0 => read * * @var int
| * Stores previous run query type: 1 => write; 0 => read * * @var int
|
Zeile 147 | Zeile 154 |
---|
{ // Simple connection to one server if(array_key_exists('hostname', $config))
|
{ // Simple connection to one server if(array_key_exists('hostname', $config))
|
{
| {
|
$connections['read'][] = $config; } // Connecting to more than one server
| $connections['read'][] = $config; } // Connecting to more than one server
|
Zeile 155 | Zeile 162 |
---|
{ // Specified multiple servers, but no specific read/write servers if(!array_key_exists('read', $config))
|
{ // Specified multiple servers, but no specific read/write servers if(!array_key_exists('read', $config))
|
{
| {
|
foreach($config as $key => $settings) { if(is_int($key))
| foreach($config as $key => $settings) { if(is_int($key))
|
Zeile 182 | Zeile 189 |
---|
}
if(array_key_exists('hostname', $connections[$type]))
|
}
if(array_key_exists('hostname', $connections[$type]))
|
{
| {
|
$details = $connections[$type]; unset($connections); $connections[$type][] = $details;
| $details = $connections[$type]; unset($connections); $connections[$type][] = $details;
|
Zeile 218 | Zeile 225 |
---|
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 230 | Zeile 237 |
---|
// 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"); return false; }
| $this->error("[READ] Unable to connect to MySQL server"); return false; }
|
Zeile 239 | Zeile 246 |
---|
{ $this->error("[WRITE] Unable to connect to MySQL server"); return false;
|
{ $this->error("[WRITE] Unable to connect to MySQL server"); return false;
|
}
| }
|
// Select databases if(!$this->select_db($config['database']))
| // Select databases if(!$this->select_db($config['database']))
|
Zeile 259 | Zeile 266 |
---|
*/ function select_db($database) {
|
*/ function select_db($database) {
|
| $this->database = $database;
|
$this->current_link = &$this->read_link; $read_success = @mysql_select_db($database, $this->read_link) or $this->error("[READ] Unable to select database", $this->read_link); if($this->write_link)
| $this->current_link = &$this->read_link; $read_success = @mysql_select_db($database, $this->read_link) or $this->error("[READ] Unable to select database", $this->read_link); if($this->write_link)
|
Zeile 367 | Zeile 376 |
---|
* * @param string $string The query SQL. * @param string $qtime The time it took to perform the query.
|
* * @param string $string The query SQL. * @param string $qtime The time it took to perform the query.
|
*/
| */
|
function explain_query($string, $qtime) { global $plugins;
| function explain_query($string, $qtime) { global $plugins;
|
Zeile 636 | Zeile 645 |
---|
{ if($prefix) {
|
{ if($prefix) {
|
$query = $this->query(" SELECT `TABLE_NAME` FROM INFORMATION_SCHEMA.TABLES WHERE `TABLE_SCHEMA` = '$database' AND `TABLE_TYPE` = 'BASE TABLE' AND `TABLE_NAME` LIKE '".$this->escape_string($prefix)."%' "); } else { $query = $this->query(" SELECT `TABLE_NAME` FROM INFORMATION_SCHEMA.TABLES WHERE `TABLE_SCHEMA` = '$database' AND `TABLE_TYPE` = 'BASE TABLE' "); }
| if(version_compare($this->get_version(), '5.0.2', '>=')) { $query = $this->query("SHOW FULL TABLES FROM `$database` WHERE table_type = 'BASE TABLE' AND `Tables_in_$database` LIKE '".$this->escape_string($prefix)."%'"); } else { $query = $this->query("SHOW TABLES FROM `$database` LIKE '".$this->escape_string($prefix)."%'"); } } else { if(version_compare($this->get_version(), '5.0.2', '>=')) { $query = $this->query("SHOW FULL TABLES FROM `$database` WHERE table_type = 'BASE TABLE'"); } else { $query = $this->query("SHOW TABLES FROM `$database`"); } }
|
$tables = array(); while(list($table) = mysql_fetch_array($query)) { $tables[] = $table;
|
$tables = array(); while(list($table) = mysql_fetch_array($query)) { $tables[] = $table;
|
}
| }
|
return $tables; }
| return $tables; }
|
Zeile 668 | Zeile 684 |
---|
function table_exists($table) { // Execute on master server to ensure if we've just created a table that we get the correct result
|
function table_exists($table) { // Execute on master server to ensure if we've just created a table that we get the correct result
|
$query = $this->write_query(" SELECT `TABLE_NAME` FROM INFORMATION_SCHEMA.TABLES WHERE `TABLE_TYPE` = 'BASE TABLE' AND `TABLE_NAME` LIKE '{$this->table_prefix}$table' ");
| if(version_compare($this->get_version(), '5.0.2', '>=')) { $query = $this->query("SHOW FULL TABLES FROM `".$this->database."` WHERE table_type = 'BASE TABLE' AND `Tables_in_".$this->database."` = '{$this->table_prefix}$table'"); } else { $query = $this->query("SHOW TABLES LIKE '{$this->table_prefix}$table'"); }
|
$exists = $this->num_rows($query); if($exists > 0) {
| $exists = $this->num_rows($query); if($exists > 0) {
|
Zeile 1457 | Zeile 1477 |
---|
'cp1251' => 'Windows Cyrillic', 'cp1256' => 'Windows Arabic', 'cp1257' => 'Windows Baltic',
|
'cp1251' => 'Windows Cyrillic', 'cp1256' => 'Windows Arabic', 'cp1257' => 'Windows Baltic',
|
'binary' => 'Binary pseudo charset',
| |
'geostd8' => 'GEOSTD8 Georgian', 'cp932' => 'SJIS for Windows Japanese', 'eucjpms' => 'UJIS for Windows Japanese',
| 'geostd8' => 'GEOSTD8 Georgian', 'cp932' => 'SJIS for Windows Japanese', 'eucjpms' => 'UJIS for Windows Japanese',
|
Zeile 1506 | Zeile 1525 |
---|
'cp1251' => 'cp1251_general_ci', 'cp1256' => 'cp1256_general_ci', 'cp1257' => 'cp1257_general_ci',
|
'cp1251' => 'cp1251_general_ci', 'cp1256' => 'cp1256_general_ci', 'cp1257' => 'cp1257_general_ci',
|
'binary' => 'binary',
| |
'geostd8' => 'geostd8_general_ci', 'cp932' => 'cp932_japanese_ci', 'eucjpms' => 'eucjpms_japanese_ci',
| 'geostd8' => 'geostd8_general_ci', 'cp932' => 'cp932_japanese_ci', 'eucjpms' => 'eucjpms_japanese_ci',
|