Vergleich inc/db_mysqli.php - 1.6.7 - 1.6.13

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 6Zeile 6
 * Website: http://mybb.com
* License: http://mybb.com/about/license
*

 * Website: http://mybb.com
* License: http://mybb.com/about/license
*

 * $Id: db_mysqli.php 5297 2010-12-28 22:01:14Z Tomm $

 * $Id$

 */

class DB_MySQLi

 */

class DB_MySQLi

Zeile 166Zeile 166
		// Actually connect to the specified servers
foreach(array('read', 'write') as $type)
{

		// Actually connect to the specified servers
foreach(array('read', 'write') as $type)
{

			if(!is_array($connections[$type]))

			if(!isset($connections[$type]) || !is_array($connections[$type]))

			{
break;
}

			{
break;
}

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

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

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

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

				{

				{

					$persist = "p:";

					$persist = 'p:';

				}

				}

				
$link = $type."_link";

$this->get_execution_time();


$link = "{$type}_link";

$this->get_execution_time();


// Specified a custom port for this connection?


// Specified a custom port for this connection?

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






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

if($port)

				{
$this->$link = @$connect_function($persist.$hostname, $single_connection['username'], $single_connection['password'], "", $port);
}
else
{
$this->$link = @$connect_function($persist.$single_connection['hostname'], $single_connection['username'], $single_connection['password']);

				{
$this->$link = @$connect_function($persist.$hostname, $single_connection['username'], $single_connection['password'], "", $port);
}
else
{
$this->$link = @$connect_function($persist.$single_connection['hostname'], $single_connection['username'], $single_connection['password']);

				}

				}


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


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

Zeile 267Zeile 272
			$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);

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

		else
{
$success = $master_success;

Zeile 291Zeile 296
	 * @param string The query SQL.
* @param boolean 1 if hide errors, 0 if not.
* @param integer 1 if executes on slave database, 0 if not.

	 * @param string The query SQL.
* @param boolean 1 if hide errors, 0 if not.
* @param integer 1 if executes on slave database, 0 if not.

	 * @return resource The query data.
*/

	 * @return resource The query data.
*/

	function query($string, $hide_errors=0, $write_query=0)
{
global $pagestarttime, $db, $mybb;

	function query($string, $hide_errors=0, $write_query=0)
{
global $pagestarttime, $db, $mybb;

Zeile 315Zeile 320
		{
$this->error($string);
exit;

		{
$this->error($string);
exit;

		}


		}


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

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

Zeile 328Zeile 333
		return $query;
}


		return $query;
}


	/**

	/**

	 * Execute a write query on the slave database
*
* @param string The query SQL.

	 * Execute a write query on the slave database
*
* @param string The query SQL.

Zeile 349Zeile 354
	function explain_query($string, $qtime)
{
global $plugins;

	function explain_query($string, $qtime)
{
global $plugins;

 

$debug_extra = '';

		if($plugins->current_hook)
{
$debug_extra = "<div style=\"float_right\">(Plugin Hook: {$plugins->current_hook})</div>";

		if($plugins->current_hook)
{
$debug_extra = "<div style=\"float_right\">(Plugin Hook: {$plugins->current_hook})</div>";

		}

		}

		if(preg_match("#^\s*select#i", $string))
{
$query = mysqli_query($this->current_link, "EXPLAIN $string");

		if(preg_match("#^\s*select#i", $string))
{
$query = mysqli_query($this->current_link, "EXPLAIN $string");

Zeile 361Zeile 368
				"<td colspan=\"8\" style=\"background-color: #ccc;\">{$debug_extra}<div><strong>#".$this->query_count." - Select Query</strong></div></td>\n".
"</tr>\n".
"<tr>\n".

				"<td colspan=\"8\" style=\"background-color: #ccc;\">{$debug_extra}<div><strong>#".$this->query_count." - Select Query</strong></div></td>\n".
"</tr>\n".
"<tr>\n".

				"<td colspan=\"8\" style=\"background-color: #fefefe;\"><span style=\"font-family: Courier; font-size: 14px;\">".$string."</span></td>\n".

				"<td colspan=\"8\" style=\"background-color: #fefefe;\"><span style=\"font-family: Courier; font-size: 14px;\">".htmlspecialchars_uni($string)."</span></td>\n".

				"</tr>\n".
"<tr style=\"background-color: #efefef;\">\n".
"<td><strong>table</strong></td>\n".

				"</tr>\n".
"<tr style=\"background-color: #efefef;\">\n".
"<td><strong>table</strong></td>\n".

Zeile 391Zeile 398
			$this->explain .=
"<tr>\n".
"<td colspan=\"8\" style=\"background-color: #fff;\">Query Time: ".$qtime."</td>\n".

			$this->explain .=
"<tr>\n".
"<td colspan=\"8\" style=\"background-color: #fff;\">Query Time: ".$qtime."</td>\n".

				"</tr>\n".
"</table>\n".
"<br />\n";
}

				"</tr>\n".
"</table>\n".
"<br />\n";
}

		else
{
$this->explain .= "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n".

		else
{
$this->explain .= "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n".

Zeile 418Zeile 425

/**
* Return a result array for a query.


/**
* Return a result array for a query.

	 *
* @param resource The query data.

	 *
* @param resource The query data.

	 * @param constant The type of array to return.
* @return array The array of results.
*/

	 * @param constant The type of array to return.
* @return array The array of results.
*/

Zeile 431Zeile 438

/**
* Return a specific field from a query.


/**
* Return a specific field from a query.

	 *
* @param resource The query ID.

	 *
* @param resource The query ID.

	 * @param string The name of the field to return.
* @param int The number of the row to fetch it from.
*/

	 * @param string The name of the field to return.
* @param int The number of the row to fetch it from.
*/

Zeile 444Zeile 451
		}
$array = $this->fetch_array($query);
return $array[$field];

		}
$array = $this->fetch_array($query);
return $array[$field];

	}

/**

	}

/**

	 * Moves internal row pointer to the next row
*
* @param resource The query ID.

	 * Moves internal row pointer to the next row
*
* @param resource The query ID.

Zeile 455Zeile 462
	function data_seek($query, $row)
{
return mysqli_data_seek($query, $row);

	function data_seek($query, $row)
{
return mysqli_data_seek($query, $row);

	}

/**

	}

/**

	 * Return the number of rows resulting from a query.
*
* @param resource The query data.

	 * Return the number of rows resulting from a query.
*
* @param resource The query data.

Zeile 494Zeile 501

/**
* Return an error number.


/**
* Return an error number.

	 *

	 *

	 * @return int The error number of the current error.
*/
function error_number()

	 * @return int The error number of the current error.
*/
function error_number()

Zeile 696Zeile 703
		$query = "SELECT ".$fields." FROM ".$this->table_prefix.$table;

if($conditions != "")

		$query = "SELECT ".$fields." FROM ".$this->table_prefix.$table;

if($conditions != "")

		{

		{

			$query .= " WHERE ".$conditions;
}


			$query .= " WHERE ".$conditions;
}


Zeile 853Zeile 860
	 */
function escape_string($string)
{

	 */
function escape_string($string)
{

 
		if($this->db_encoding == 'utf8')
{
$string = validate_utf8_string($string, false);
}
elseif($this->db_encoding == 'utf8mb4')
{
$string = validate_utf8_string($string);
}


		if(function_exists("mysqli_real_escape_string") && $this->read_link)
{
$string = mysqli_real_escape_string($this->read_link, $string);

		if(function_exists("mysqli_real_escape_string") && $this->read_link)
{
$string = mysqli_real_escape_string($this->read_link, $string);

Zeile 998Zeile 1014
		$query = $this->write_query("SHOW TABLE STATUS LIKE '{$this->table_prefix}$table'");
$status = $this->fetch_array($query);
$table_type = my_strtoupper($status['Engine']);

		$query = $this->write_query("SHOW TABLE STATUS LIKE '{$this->table_prefix}$table'");
$status = $this->fetch_array($query);
$table_type = my_strtoupper($status['Engine']);

		if($version >= '3.23.23' && $table_type == 'MYISAM')





		if(version_compare($version, '3.23.23', '>=') && ($table_type == 'MYISAM' || $table_type == 'ARIA'))
{
return true;
}
elseif(version_compare($version, '5.6', '>=') && $table_type == 'INNODB')

		{
return true;
}

		{
return true;
}

Zeile 1015Zeile 1035
	{
$version = $this->get_version();
$supports_fulltext = $this->supports_fulltext($table);

	{
$version = $this->get_version();
$supports_fulltext = $this->supports_fulltext($table);

		if($version >= '4.0.1' && $supports_fulltext == true)

		if(version_compare($version, '4.0.1', '>=') && $supports_fulltext == true)

		{
return true;
}

		{
return true;
}

Zeile 1240Zeile 1260
			'latin5' => 'ISO 8859-9 Turkish',
'armscii8' => 'ARMSCII-8 Armenian',
'utf8' => 'UTF-8 Unicode',

			'latin5' => 'ISO 8859-9 Turkish',
'armscii8' => 'ARMSCII-8 Armenian',
'utf8' => 'UTF-8 Unicode',

 
			'utf8mb4' => '4-Byte UTF-8 Unicode (requires MySQL 5.5.3 or above)',

			'ucs2' => 'UCS-2 Unicode',
'cp866' => 'DOS Russian',
'keybcs2' => 'DOS Kamenicky Czech-Slovak',

			'ucs2' => 'UCS-2 Unicode',
'cp866' => 'DOS Russian',
'keybcs2' => 'DOS Kamenicky Czech-Slovak',

Zeile 1288Zeile 1309
			'latin5' => 'latin5_turkish_ci',
'armscii8' => 'armscii8_general_ci',
'utf8' => 'utf8_general_ci',

			'latin5' => 'latin5_turkish_ci',
'armscii8' => 'armscii8_general_ci',
'utf8' => 'utf8_general_ci',

 
			'utf8mb4' => 'utf8mb4_general_ci',

			'ucs2' => 'ucs2_general_ci',
'cp866' => 'cp866_general_ci',
'keybcs2' => 'keybcs2_general_ci',

			'ucs2' => 'ucs2_general_ci',
'cp866' => 'cp866_general_ci',
'keybcs2' => 'keybcs2_general_ci',