Vergleich inc/db_mysqli.php - 1.8.21 - 1.8.31

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

if(array_key_exists('hostname', $connections[$type]))
{
$details = $connections[$type];

				break;
}

if(array_key_exists('hostname', $connections[$type]))
{
$details = $connections[$type];

				unset($connections);

				unset($connections[$type]);

				$connections[$type][] = $details;
}


				$connections[$type][] = $details;
}


Zeile 203Zeile 208
				$connect_function = "mysqli_connect";
$persist = "";
if(!empty($single_connection['pconnect']) && version_compare(PHP_VERSION, '5.3.0', '>='))

				$connect_function = "mysqli_connect";
$persist = "";
if(!empty($single_connection['pconnect']) && version_compare(PHP_VERSION, '5.3.0', '>='))

				{

				{

					$persist = 'p:';
}


					$persist = 'p:';
}


Zeile 216Zeile 221
				if(strstr($single_connection['hostname'],':'))
{
list($hostname, $port) = explode(":", $single_connection['hostname'], 2);

				if(strstr($single_connection['hostname'],':'))
{
list($hostname, $port) = explode(":", $single_connection['hostname'], 2);

				}

				}


if($port)
{


if($port)
{

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

		$this->database = $database;

$master_success = @mysqli_select_db($this->read_link, $database) or $this->error("[READ] Unable to select database", $this->read_link);

Zeile 317Zeile 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 server

		get_execution_time();

// Only execute write queries on master server

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

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

Zeile 356Zeile 361
			$this->explain_query($string, $query_time);
}
return $query;

			$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 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 1035Zeile 1044
	 */
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 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}");

	}

/**

	}

/**