Vergleich inc/db_mysql.php - 1.6.4 - 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_mysql.php 5297 2010-12-28 22:01:14Z Tomm $

 * $Id$

 */

class DB_MySQL

 */

class DB_MySQL

Zeile 185Zeile 185
			foreach($connections[$type] as $single_connection)
{
$connect_function = "mysql_connect";

			foreach($connections[$type] as $single_connection)
{
$connect_function = "mysql_connect";

				if($single_connection['pconnect'])

				if(isset($single_connection['pconnect']))

				{
$connect_function = "mysql_pconnect";
}

				{
$connect_function = "mysql_pconnect";
}

				
$link = $type."_link";


$link = "{$type}_link";


$this->get_execution_time();



$this->get_execution_time();


Zeile 340Zeile 340
	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>";

Zeile 352Zeile 354
				"<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 393
			$this->explain .= "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n".
"<tr>\n".
"<td style=\"background-color: #ccc;\">{$debug_extra}<div><strong>#".$this->query_count." - Write Query</strong></div></td>\n".

			$this->explain .= "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n".
"<tr>\n".
"<td style=\"background-color: #ccc;\">{$debug_extra}<div><strong>#".$this->query_count." - Write Query</strong></div></td>\n".

				"</tr>\n".

				"</tr>\n".

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

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

Zeile 415Zeile 417
	 * @return array The array of results.
*/
function fetch_array($query)

	 * @return array The array of results.
*/
function fetch_array($query)

	{

	{

		$array = mysql_fetch_assoc($query);
return $array;
}

		$array = mysql_fetch_assoc($query);
return $array;
}

Zeile 428Zeile 430
	 * @param int The number of the row to fetch it from.
*/
function fetch_field($query, $field, $row=false)

	 * @param int The number of the row to fetch it from.
*/
function fetch_field($query, $field, $row=false)

	{

	{

		if($row === false)

		if($row === false)

		{

		{

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

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

		}

		}

		else
{
return mysql_result($query, $row, $field);

		else
{
return mysql_result($query, $row, $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 453Zeile 455

/**
* Return the number of rows resulting from a query.


/**
* Return the number of rows resulting from a query.

	 *

	 *

	 * @param resource The query ID.
* @return int The number of rows in the result.
*/

	 * @param resource The query ID.
* @return int The number of rows in the result.
*/

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

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

	{
if($this->current_link)

	{
if($this->current_link)

		{
return @mysql_errno($this->current_link);
}

		{
return @mysql_errno($this->current_link);
}

Zeile 512Zeile 514
		if($this->current_link)
{
return @mysql_error($this->current_link);

		if($this->current_link)
{
return @mysql_error($this->current_link);

		}
else
{
return @mysql_error();

		}
else
{
return @mysql_error();

		}
}


		}
}


Zeile 565Zeile 567
	function affected_rows()
{
return mysql_affected_rows($this->current_link);

	function affected_rows()
{
return mysql_affected_rows($this->current_link);

	}

	}


/**
* Return the number of fields.


/**
* Return the number of fields.

Zeile 590Zeile 592
		if($prefix)
{
$query = $this->query("SHOW TABLES FROM `$database` LIKE '".$this->escape_string($prefix)."%'");

		if($prefix)
{
$query = $this->query("SHOW TABLES FROM `$database` LIKE '".$this->escape_string($prefix)."%'");

		}
else
{

		}
else
{

			$query = $this->query("SHOW TABLES FROM `$database`");
}


			$query = $this->query("SHOW TABLES FROM `$database`");
}


Zeile 616Zeile 618
		$query = $this->write_query("
SHOW TABLES
LIKE '{$this->table_prefix}$table'

		$query = $this->write_query("
SHOW TABLES
LIKE '{$this->table_prefix}$table'

		");
$exists = $this->num_rows($query);
if($exists > 0)

		");
$exists = $this->num_rows($query);
if($exists > 0)

		{
return true;

		{
return true;

		}

		}

		else
{
return false;

		else
{
return false;

Zeile 630Zeile 632

/**
* Check if a field exists in a database.


/**
* Check if a field exists in a database.

	 *

	 *

	 * @param string The field name.
* @param string The table name.
* @return boolean True when exists, false if not.

	 * @param string The field name.
* @param string The table name.
* @return boolean True when exists, false if not.

Zeile 693Zeile 695
			if(isset($options['order_dir']))
{
$query .= " ".my_strtoupper($options['order_dir']);

			if(isset($options['order_dir']))
{
$query .= " ".my_strtoupper($options['order_dir']);

			}

			}

		}
if(isset($options['limit_start']) && isset($options['limit']))

		}
if(isset($options['limit_start']) && isset($options['limit']))

		{

		{

			$query .= " LIMIT ".$options['limit_start'].", ".$options['limit'];

			$query .= " LIMIT ".$options['limit_start'].", ".$options['limit'];

		}

		}

		elseif(isset($options['limit']))
{
$query .= " LIMIT ".$options['limit'];
}
return $this->query($query);

		elseif(isset($options['limit']))
{
$query .= " LIMIT ".$options['limit'];
}
return $this->query($query);

	}


	}


	/**
* Build an insert query from an array.
*

	/**
* Build an insert query from an array.
*

Zeile 714Zeile 716
	 * @return int The insert ID if available
*/
function insert_query($table, $array)

	 * @return int The insert ID if available
*/
function insert_query($table, $array)

	{
if(!is_array($array))
{
return false;

	{
if(!is_array($array))
{
return false;

		}
$fields = "`".implode("`,`", array_keys($array))."`";
$values = implode("','", $array);

		}
$fields = "`".implode("`,`", array_keys($array))."`";
$values = implode("','", $array);

Zeile 729Zeile 731
		return $this->insert_id();
}


		return $this->insert_id();
}


	/**

	/**

	 * Build one query for multiple inserts from a multidimensional array.
*
* @param string The table name to perform the query on.

	 * Build one query for multiple inserts from a multidimensional array.
*
* @param string The table name to perform the query on.

Zeile 737Zeile 739
	 * @return int The insert ID if available
*/
function insert_query_multiple($table, $array)

	 * @return int The insert ID if available
*/
function insert_query_multiple($table, $array)

	{
if(!is_array($array))
{
return false;
}

	{
if(!is_array($array))
{
return false;
}

		// Field names
$fields = array_keys($array[0]);
$fields = "`".implode("`,`", $fields)."`";

		// Field names
$fields = array_keys($array[0]);
$fields = "`".implode("`,`", $fields)."`";

Zeile 790Zeile 792
		{
$query .= $comma."`".$field."`={$quote}{$value}{$quote}";
$comma = ', ';

		{
$query .= $comma."`".$field."`={$quote}{$value}{$quote}";
$comma = ', ';

		}

if(!empty($where))
{
$query .= " WHERE $where";
}

if(!empty($limit))
{
$query .= " LIMIT $limit";
}

		}

if(!empty($where))
{
$query .= " WHERE $where";
}

if(!empty($limit))
{
$query .= " LIMIT $limit";
}

		
return $this->write_query("
UPDATE {$this->table_prefix}$table
SET $query

		
return $this->write_query("
UPDATE {$this->table_prefix}$table
SET $query

		");
}

		");
}


/**
* Build a delete query.


/**
* Build a delete query.

Zeile 825Zeile 827
		}

if(!empty($limit))

		}

if(!empty($limit))

		{

		{

			$query .= " LIMIT $limit";
}


			$query .= " LIMIT $limit";
}


Zeile 845Zeile 847
	 */
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("mysql_real_escape_string") && $this->read_link)
{
$string = mysql_real_escape_string($string, $this->read_link);

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

Zeile 996Zeile 1007
		{
$table_type = my_strtoupper($status['Type']);
}

		{
$table_type = my_strtoupper($status['Type']);
}

		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 1040Zeile 1055
	{
$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 1244Zeile 1259
			'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 1292Zeile 1308
			'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',