Vergleich inc/db_mysqli.php - 1.8.6 - 1.8.20

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

	 * @var mysqli
*/
public $current_link;

 

/**
* The database name.
*
* @var string
*/
public $database;


/**
* Explanation of a query.


/**
* Explanation of a query.

Zeile 273Zeile 280
	 */
function select_db($database)
{

	 */
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)
{

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

Zeile 632Zeile 641
	{
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)."%'
");




			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

		}
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'");
}
else
{
$query = $this->query("SHOW TABLES FROM `$database`");
}

		}

$tables = array();
while(list($table) = mysqli_fetch_array($query))
{
$tables[] = $table;

		}

$tables = array();
while(list($table) = mysqli_fetch_array($query))
{
$tables[] = $table;

		}


		}


		return $tables;
}

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

		return $tables;
}

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

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

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

	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'
");
$exists = $this->num_rows($query);

if($exists > 0)
{
return true;
}
else
{
return false;
}
}

/**




		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)
{
return true;
}
else
{
return false;
}
}

/**

	 * Check if a field exists in a database.
*
* @param string $field The field name.

	 * Check if a field exists in a database.
*
* @param string $field The field name.

Zeile 716Zeile 736
	{
global $shutdown_queries;
if($name)

	{
global $shutdown_queries;
if($name)

		{

		{

			$shutdown_queries[$name] = $query;
}
else

			$shutdown_queries[$name] = $query;
}
else

Zeile 735Zeile 755
	 * @return mysqli_result The query data.
*/
function simple_select($table, $fields="*", $conditions="", $options=array())

	 * @return mysqli_result The query data.
*/
function simple_select($table, $fields="*", $conditions="", $options=array())

	{

	{

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

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





		if($conditions != "")

		if($conditions != "")

		{

		{

			$query .= " WHERE ".$conditions;

			$query .= " WHERE ".$conditions;

		}


		}


		if(isset($options['group_by']))

		if(isset($options['group_by']))

		{

		{

			$query .= " GROUP BY ".$options['group_by'];
}


			$query .= " GROUP BY ".$options['group_by'];
}


Zeile 754Zeile 774
			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']))

Zeile 792Zeile 812
				if($value[0] != 'X') // Not escaped?
{
$value = $this->escape_binary($value);

				if($value[0] != 'X') // Not escaped?
{
$value = $this->escape_binary($value);

				}


				}


				$array[$field] = $value;
}
else

				$array[$field] = $value;
}
else

Zeile 872Zeile 892
	 * @return mysqli_result The query data.
*/
function update_query($table, $array, $where="", $limit="", $no_quote=false)

	 * @return mysqli_result The query data.
*/
function update_query($table, $array, $where="", $limit="", $no_quote=false)

	{
global $mybb;


	{
global $mybb;


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

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

Zeile 907Zeile 927
				$query .= $comma."`".$field."`={$quoted_value}";
}
$comma = ', ';

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

		}

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

		}

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

		}

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

		}

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

Zeile 930Zeile 950
	 * @param string $quote
*
* @return int|string

	 * @param string $quote
*
* @return int|string

	 */

	 */

	private function quote_val($value, $quote="'")
{
if(is_int($value))

	private function quote_val($value, $quote="'")
{
if(is_int($value))

Zeile 969Zeile 989

/**
* Escape a string according to the MySQL escape format.


/**
* Escape a string according to the MySQL escape format.

	 *

	 *

	 * @param string $string The string to be escaped.
* @return string The escaped string.
*/

	 * @param string $string The string to be escaped.
* @return string The escaped string.
*/

Zeile 1028Zeile 1048
		if($this->version)
{
return $this->version;

		if($this->version)
{
return $this->version;

		}

$version = @mysqli_get_server_info($this->read_link);
if(!$version)
{
$query = $this->query("SELECT VERSION() as version");
$ver = $this->fetch_array($query);
$version = $ver['version'];
}

		}

$query = $this->query("SELECT VERSION() as version");
$ver = $this->fetch_array($query);
$version = $ver['version'];






if($version)
{


if($version)
{

Zeile 1054Zeile 1070
	function optimize_table($table)
{
$this->write_query("OPTIMIZE TABLE ".$this->table_prefix.$table."");

	function optimize_table($table)
{
$this->write_query("OPTIMIZE TABLE ".$this->table_prefix.$table."");

	}

	}


/**
* Analyzes a specific table.


/**
* Analyzes a specific table.

Zeile 1093Zeile 1109
		while($field = $this->fetch_array($query))
{
$field_info[] = $field;

		while($field = $this->fetch_array($query))
{
$field_info[] = $field;

		}

		}

		return $field_info;
}


		return $field_info;
}


Zeile 1133Zeile 1149
	 */

function supports_fulltext($table)

	 */

function supports_fulltext($table)

	{

	{

		$version = $this->get_version();
$query = $this->write_query("SHOW TABLE STATUS LIKE '{$this->table_prefix}$table'");
$status = $this->fetch_array($query);

		$version = $this->get_version();
$query = $this->write_query("SHOW TABLE STATUS LIKE '{$this->table_prefix}$table'");
$status = $this->fetch_array($query);

Zeile 1192Zeile 1208
		}

return false;

		}

return false;

	}

/**

	}

/**

	 * Creates a fulltext index on the specified column in the specified table with optional index name.
*
* @param string $table The name of the table.

	 * Creates a fulltext index on the specified column in the specified table with optional index name.
*
* @param string $table The name of the table.

Zeile 1225Zeile 1241
	 * @param boolean $table_prefix use table prefix
*/
function drop_table($table, $hard=false, $table_prefix=true)

	 * @param boolean $table_prefix use table prefix
*/
function drop_table($table, $hard=false, $table_prefix=true)

	{
if($table_prefix == false)
{
$table_prefix = "";
}
else
{
$table_prefix = $this->table_prefix;
}


	{
if($table_prefix == false)
{
$table_prefix = "";
}
else
{
$table_prefix = $this->table_prefix;
}


		if($hard == false)
{
$this->write_query('DROP TABLE IF EXISTS '.$table_prefix.$table);

		if($hard == false)
{
$this->write_query('DROP TABLE IF EXISTS '.$table_prefix.$table);

Zeile 1272Zeile 1288
	 *
* @param string $table The table
* @param array $replacements The replacements

	 *
* @param string $table The table
* @param array $replacements The replacements

 
	 * @param string|array $default_field The default field(s)
* @param boolean $insert_id Whether or not to return an insert id. True by default

	 * @return mysqli_result|bool

	 * @return mysqli_result|bool

	 */
function replace_query($table, $replacements=array())

	 */
function replace_query($table, $replacements=array(), $default_field="", $insert_id=true)

	{
global $mybb;


	{
global $mybb;


Zeile 1309Zeile 1327

/**
* Drops a column


/**
* Drops a column

	 *
* @param string $table The table
* @param string $column The column name
* @return mysqli_result
*/

	 *
* @param string $table The table
* @param string $column The column name
* @return mysqli_result
*/

	function drop_column($table, $column)

	function drop_column($table, $column)

	{
return $this->write_query("ALTER TABLE {$this->table_prefix}{$table} DROP {$column}");
}

/**



	{
$column = trim($column, '`');

return $this->write_query("ALTER TABLE {$this->table_prefix}{$table} DROP `{$column}`");
}

/**

	 * Adds a column
*
* @param string $table The table

	 * Adds a column
*
* @param string $table The table

Zeile 1329Zeile 1349
	 */
function add_column($table, $column, $definition)
{

	 */
function add_column($table, $column, $definition)
{

		return $this->write_query("ALTER TABLE {$this->table_prefix}{$table} ADD {$column} {$definition}");



		$column = trim($column, '`');

return $this->write_query("ALTER TABLE {$this->table_prefix}{$table} ADD `{$column}` {$definition}");

	}

/**
* Modifies a column

	}

/**
* Modifies a column

	 *
* @param string $table The table

	 *
* @param string $table The table

	 * @param string $column The column name

	 * @param string $column The column name

	 * @param string $new_definition the new column definition
* @return mysqli_result

	 * @param string $new_definition the new column definition
* @return mysqli_result

	 */
function modify_column($table, $column, $new_definition)
{

	 */
function modify_column($table, $column, $new_definition)
{

		return $this->write_query("ALTER TABLE {$this->table_prefix}{$table} MODIFY {$column} {$new_definition}");
}



		$column = trim($column, '`');

return $this->write_query("ALTER TABLE {$this->table_prefix}{$table} MODIFY `{$column}` {$new_definition}");
}


/**
* Renames a column


/**
* Renames a column

Zeile 1356Zeile 1380
	 */
function rename_column($table, $old_column, $new_column, $new_definition)
{

	 */
function rename_column($table, $old_column, $new_column, $new_definition)
{

		return $this->write_query("ALTER TABLE {$this->table_prefix}{$table} CHANGE {$old_column} {$new_column} {$new_definition}");




		$old_column = trim($old_column, '`');
$new_column = trim($new_column, '`');

return $this->write_query("ALTER TABLE {$this->table_prefix}{$table} CHANGE `{$old_column}` `{$new_column}` {$new_definition}");

	}

/**

	}

/**

Zeile 1438Zeile 1465
			'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 1487Zeile 1513
			'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',