Vergleich inc/db_mysqli.php - 1.8.24 - 1.8.33

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 72Zeile 72
	 * @var mysqli
*/
public $current_link;

	 * @var mysqli
*/
public $current_link;

 

/**
* @var array
*/
public $connections = array();


/**
* The database name.


/**
* The database name.

Zeile 174Zeile 179
			else
{
$connections = $config;

			else
{
$connections = $config;

			}
}


			}
}


		$this->db_encoding = $config['encoding'];

// Actually connect to the specified servers
foreach(array('read', 'write') as $type)
{
if(!isset($connections[$type]) || !is_array($connections[$type]))

		$this->db_encoding = $config['encoding'];

// Actually connect to the specified servers
foreach(array('read', 'write') as $type)
{
if(!isset($connections[$type]) || !is_array($connections[$type]))

			{

			{

				break;
}


				break;
}


Zeile 196Zeile 201

// Shuffle the connections
shuffle($connections[$type]);


// Shuffle the connections
shuffle($connections[$type]);





			// Loop-de-loop
foreach($connections[$type] as $single_connection)
{

			// Loop-de-loop
foreach($connections[$type] as $single_connection)
{

Zeile 228Zeile 233
				}

$time_spent = get_execution_time();

				}

$time_spent = get_execution_time();

				$this->query_time += $time_spent;

				$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;


// 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;

				}

				}

				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))
{
$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)
{
$this->error("[READ] Unable to connect to MySQL server");

		// Have no read connection?
if(!$this->read_link)
{
$this->error("[READ] Unable to connect to MySQL server");

			return false;
}

			return false;
}

		// No write?
else if(!$this->write_link)
{
$this->error("[WRITE] Unable to connect to MySQL server");
return false;

		// No write?
else if(!$this->write_link)
{
$this->error("[WRITE] Unable to connect to MySQL server");
return false;

		}

		}


// Select databases
if(!$this->select_db($config['database']))
{
return -1;
}


// Select databases
if(!$this->select_db($config['database']))
{
return -1;
}





		$this->current_link = &$this->read_link;
return $this->read_link;
}

		$this->current_link = &$this->read_link;
return $this->read_link;
}

Zeile 279Zeile 284
	 * @return boolean True when successfully connected, false if not.
*/
function select_db($database)

	 * @return boolean True when successfully connected, false if not.
*/
function select_db($database)

	{

	{

		$this->database = $database;

$master_success = @mysqli_select_db($this->read_link, $database) or $this->error("[READ] Unable to select database", $this->read_link);
if($this->write_link)
{
$slave_success = @mysqli_select_db($this->write_link, $database) or $this->error("[WRITE] Unable to select slave database", $this->write_link);

		$this->database = $database;

$master_success = @mysqli_select_db($this->read_link, $database) or $this->error("[READ] Unable to select database", $this->read_link);
if($this->write_link)
{
$slave_success = @mysqli_select_db($this->write_link, $database) or $this->error("[WRITE] Unable to select slave database", $this->write_link);





			$success = ($master_success && $slave_success ? true : false);
}
else
{
$success = $master_success;

			$success = ($master_success && $slave_success ? true : false);
}
else
{
$success = $master_success;

		}

		}


if($success && $this->db_encoding)
{


if($success && $this->db_encoding)
{

Zeile 305Zeile 310
		}
return $success;
}

		}
return $success;
}





	/**
* Query the database.
*

	/**
* Query the database.
*

Zeile 330Zeile 335
		{
$this->current_link = &$this->read_link;
$query = @mysqli_query($this->read_link, $string);

		{
$this->current_link = &$this->read_link;
$query = @mysqli_query($this->read_link, $string);

		}


		}


		if($this->error_number() && !$hide_errors)
{
$this->error($string);
exit;

		if($this->error_number() && !$hide_errors)
{
$this->error($string);
exit;

		}


		}


		if($write_query)
{
$this->last_query_type = 1;
}
else

		if($write_query)
{
$this->last_query_type = 1;
}
else

		{

		{

			$this->last_query_type = 0;
}

$query_time = get_execution_time();
$this->query_time += $query_time;
$this->query_count++;

			$this->last_query_type = 0;
}

$query_time = get_execution_time();
$this->query_time += $query_time;
$this->query_count++;





		if($mybb->debug_mode)
{
$this->explain_query($string, $query_time);
}
return $query;

		if($mybb->debug_mode)
{
$this->explain_query($string, $query_time);
}
return $query;

	}

	}


/**
* Execute a write query on the master database


/**
* Execute a write query on the master database

Zeile 369Zeile 374
	{
return $this->query($query, $hide_errors, 1);
}

	{
return $this->query($query, $hide_errors, 1);
}





	/**
* Explain a query on the database.
*

	/**
* Explain a query on the database.
*

Zeile 382Zeile 387

$debug_extra = '';
if($plugins->current_hook)


$debug_extra = '';
if($plugins->current_hook)

		{

		{

			$debug_extra = "<div style=\"float_right\">(Plugin Hook: {$plugins->current_hook})</div>";
}
if(preg_match("#^\s*select#i", $string))

			$debug_extra = "<div style=\"float_right\">(Plugin Hook: {$plugins->current_hook})</div>";
}
if(preg_match("#^\s*select#i", $string))

Zeile 485Zeile 490
			$this->data_seek($query, $row);
}
$array = $this->fetch_array($query);

			$this->data_seek($query, $row);
}
$array = $this->fetch_array($query);

		return $array[$field];





		if($array !== null)
{
return $array[$field];
}
return null;

	}

/**

	}

/**

Zeile 1384Zeile 1393
			$not_null = '';
}


			$not_null = '';
}


		if($new_default_value !== null)

		if($new_default_value !== false)

		{
$default = "DEFAULT ".$new_default_value;
}

		{
$default = "DEFAULT ".$new_default_value;
}

Zeile 1393Zeile 1402
			$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}");

	}

/**

	}

/**