Vergleich inc/db_mysql.php - 1.8.5 - 1.8.26

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

	 * @var resource
*/
public $current_link;

 

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


/**
* Explanation of a query.


/**
* Explanation of a query.

Zeile 140Zeile 147
	/**
* Connect to the database server.
*

	/**
* Connect to the database server.
*

	 * @param array Array of DBMS connection details.

	 * @param array $config Array of DBMS connection details.

	 * @return resource The DB connection resource. Returns false on fail or -1 on a db connect failure.
*/
function connect($config)

	 * @return resource The DB connection resource. Returns false on fail or -1 on a db connect failure.
*/
function connect($config)

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

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

				unset($connections);

				unset($connections[$type]);

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


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


Zeile 254Zeile 261
	/**
* Selects the database to use.
*

	/**
* Selects the database to use.
*

	 * @param string The database name.

	 * @param string $database The database name.

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

		global $mybb;


		$this->database = $database;


		$this->current_link = &$this->read_link;
$read_success = @mysql_select_db($database, $this->read_link) or $this->error("[READ] Unable to select database", $this->read_link);
if($this->write_link)

		$this->current_link = &$this->read_link;
$read_success = @mysql_select_db($database, $this->read_link) or $this->error("[READ] Unable to select database", $this->read_link);
if($this->write_link)

Zeile 268Zeile 275
			$this->current_link = &$this->write_link;
$write_success = @mysql_select_db($database, $this->write_link) or $this->error("[WRITE] Unable to select database", $this->write_link);
$success = ($read_success && $write_success ? true : false);

			$this->current_link = &$this->write_link;
$write_success = @mysql_select_db($database, $this->write_link) or $this->error("[WRITE] Unable to select database", $this->write_link);
$success = ($read_success && $write_success ? true : false);

		}

		}

		else
{
$success = $read_success;

		else
{
$success = $read_success;

		}


		}


		if($success && $this->db_encoding)
{
// A little magic to support PHP 5.2.0, 5.2.1 and 5.2.2

		if($success && $this->db_encoding)
{
// A little magic to support PHP 5.2.0, 5.2.1 and 5.2.2

Zeile 301Zeile 308

/**
* Query the database.


/**
* Query the database.

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

	 *
* @param string $string The query SQL.
* @param integer $hide_errors 1 if hide errors, 0 if not.
* @param integer $write_query 1 if executes on master database, 0 if not.

	 * @return resource The query data.
*/
function query($string, $hide_errors=0, $write_query=0)
{

	 * @return resource The query data.
*/
function query($string, $hide_errors=0, $write_query=0)
{

		global $pagestarttime, $db, $mybb;

		global $mybb;


get_execution_time();



get_execution_time();


Zeile 318Zeile 325
		{
$this->current_link = &$this->write_link;
$query = @mysql_query($string, $this->write_link);

		{
$this->current_link = &$this->write_link;
$query = @mysql_query($string, $this->write_link);

		}

		}

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

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

		}


		}


		if($this->error_number() && !$hide_errors)

		if($this->error_number() && !$hide_errors)

		{

		{

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

if($write_query)

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

if($write_query)

		{

		{

			$this->last_query_type = 1;
}
else

			$this->last_query_type = 1;
}
else

Zeile 355Zeile 362
	/**
* Execute a write query on the master database
*

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

	 * @param string The query SQL.
* @param boolean 1 if hide errors, 0 if not.

	 * @param string $query The query SQL.
* @param boolean|int $hide_errors 1 if hide errors, 0 if not.

	 * @return resource The query data.
*/
function write_query($query, $hide_errors=0)

	 * @return resource The query data.
*/
function write_query($query, $hide_errors=0)

Zeile 367Zeile 374
	/**
* Explain a query on the database.
*

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

	 * @param string The query SQL.
* @param string The time it took to perform the query.

	 * @param string $string The query SQL.
* @param string $qtime The time it took to perform the query.

	 */
function explain_query($string, $qtime)
{

	 */
function explain_query($string, $qtime)
{

Zeile 378Zeile 385
		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 = mysql_query("EXPLAIN $string", $this->current_link);

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

Zeile 444Zeile 451
	/**
* Return a result array for a query.
*

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

	 * @param resource The query ID.
* @param constant The type of array to return.

	 * @param resource $query The query ID.
* @param int $resulttype The type of array to return. Either MYSQL_NUM, MYSQL_BOTH or MYSQL_ASSOC

	 * @return array The array of results.
*/
function fetch_array($query, $resulttype=MYSQL_ASSOC)

	 * @return array The array of results.
*/
function fetch_array($query, $resulttype=MYSQL_ASSOC)

Zeile 468Zeile 475
	/**
* Return a specific field from a query.
*

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

	 * @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 resource $query The query ID.
* @param string $field The name of the field to return.
* @param int|bool $row The number of the row to fetch it from.
* @return mixed

	 */
function fetch_field($query, $field, $row=false)
{

	 */
function fetch_field($query, $field, $row=false)
{

Zeile 488Zeile 496
	/**
* Moves internal row pointer to the next row
*

	/**
* Moves internal row pointer to the next row
*

	 * @param resource The query ID.
* @param int The pointer to move the row to.


	 * @param resource $query The query ID.
* @param int $row The pointer to move the row to.
* @return bool

	 */
function data_seek($query, $row)
{

	 */
function data_seek($query, $row)
{

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

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

	 * @param resource The query ID.

	 * @param resource $query The query ID.

	 * @return int The number of rows in the result.
*/
function num_rows($query)

	 * @return int The number of rows in the result.
*/
function num_rows($query)

Zeile 567Zeile 576
	/**
* Output a database error.
*

	/**
* Output a database error.
*

	 * @param string The string to present as an error.


	 * @param string $string The string to present as an error.
* @return bool Returns false if error reporting is disabled, otherwise true

	 */
function error($string="")
{

	 */
function error($string="")
{

Zeile 594Zeile 604
			{
trigger_error("<strong>[SQL] [".$this->error_number()."] ".$this->error_string()."</strong><br />{$string}", E_USER_ERROR);
}

			{
trigger_error("<strong>[SQL] [".$this->error_number()."] ".$this->error_string()."</strong><br />{$string}", E_USER_ERROR);
}

 

return true;

		}
else
{

		}
else
{

Zeile 607Zeile 619
	 * @return int The number of affected rows.
*/
function affected_rows()

	 * @return int The number of affected rows.
*/
function affected_rows()

	{
return mysql_affected_rows($this->current_link);
}

/**
* Return the number of fields.
*
* @param resource The query ID.
* @return int The number of fields.
*/

	{
return mysql_affected_rows($this->current_link);
}

/**
* Return the number of fields.
*
* @param resource $query The query ID.
* @return int The number of fields.
*/

	function num_fields($query)
{
return mysql_num_fields($query);

	function num_fields($query)
{
return mysql_num_fields($query);

Zeile 625Zeile 637
	/**
* Lists all tables in the database.
*

	/**
* Lists all tables in the database.
*

	 * @param string The database name.
* @param string Prefix of the table (optional)

	 * @param string $database The database name.
* @param string $prefix Prefix of the table (optional)

	 * @return array The table list.
*/
function list_tables($database, $prefix='')
{
if($prefix)
{

	 * @return array The table list.
*/
function list_tables($database, $prefix='')
{
if($prefix)
{

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








			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) = mysql_fetch_array($query))

		}

$tables = array();
while(list($table) = mysql_fetch_array($query))

		{

		{

			$tables[] = $table;
}

			$tables[] = $table;
}





		return $tables;
}

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

		return $tables;
}

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

	 *
* @param string 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("
SHOW TABLES
LIKE '{$this->table_prefix}$table'
");






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

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

Zeile 676Zeile 707
	/**
* 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.

	 * @param string $field The field name.
* @param string $table The table name.

	 * @return boolean True when exists, false if not.
*/
function field_exists($field, $table)

	 * @return boolean True when exists, false if not.
*/
function field_exists($field, $table)

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

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

		{
return true;
}
else
{

		{
return true;
}
else
{

			return false;

			return false;

		}

		}

	}

/**
* Add a shutdown query.
*

	}

/**
* Add a shutdown query.
*

	 * @param resource The query data.
* @param string An optional name for the query.

	 * @param resource $query The query data.
* @param string $name An optional name for the query.

	 */

	 */

	function shutdown_query($query, $name=0)

	function shutdown_query($query, $name="")

	{
global $shutdown_queries;
if($name)
{
$shutdown_queries[$name] = $query;
}

	{
global $shutdown_queries;
if($name)
{
$shutdown_queries[$name] = $query;
}

		else
{
$shutdown_queries[] = $query;
}

		else
{
$shutdown_queries[] = $query;
}

	}
/**
* Performs a simple select query.
*

	}
/**
* Performs a simple select query.
*

	 * @param string The table name to be queried.
* @param string Comma delimetered list of fields to be selected.
* @param string SQL formatted list of conditions to be matched.
* @param array List of options: group by, order by, order direction, limit, limit start.

	 * @param string $table The table name to be queried.
* @param string $fields Comma delimetered list of fields to be selected.
* @param string $conditions SQL formatted list of conditions to be matched.
* @param array $options List of options: group by, order by, order direction, limit, limit start.

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

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

Zeile 754Zeile 785
		elseif(isset($options['limit']))
{
$query .= " LIMIT ".$options['limit'];

		elseif(isset($options['limit']))
{
$query .= " LIMIT ".$options['limit'];

		}

		}


return $this->query($query);
}


return $this->query($query);
}





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

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

	 * @param string The table name to perform the query on.
* @param array An array of fields and their values.

	 * @param string $table The table name to perform the query on.
* @param array $array An array of fields and their values.

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

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

Zeile 773Zeile 804
		if(!is_array($array))
{
return false;

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

		}


		}


		foreach($array as $field => $value)
{
if(isset($mybb->binary_fields[$table][$field]) && $mybb->binary_fields[$table][$field])

		foreach($array as $field => $value)
{
if(isset($mybb->binary_fields[$table][$field]) && $mybb->binary_fields[$table][$field])

Zeile 805Zeile 836
	/**
* Build one query for multiple inserts from a multidimensional array.
*

	/**
* Build one query for multiple inserts from a multidimensional array.
*

	 * @param string The table name to perform the query on.
* @param array An array of inserts.
* @return int The insert ID if available

	 * @param string $table The table name to perform the query on.
* @param array $array An array of inserts.
* @return void

	 */
function insert_query_multiple($table, $array)
{

	 */
function insert_query_multiple($table, $array)
{

Zeile 815Zeile 846

if(!is_array($array))
{


if(!is_array($array))
{

			return false;

			return;

		}

		}

 


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

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

Zeile 848Zeile 880
			INSERT
INTO {$this->table_prefix}{$table} ({$fields})
VALUES {$insert_rows}

			INSERT
INTO {$this->table_prefix}{$table} ({$fields})
VALUES {$insert_rows}

		");
}

		");
}


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


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

	 * @param string The table name to perform the query on.
* @param array An array of fields and their values.
* @param string An optional where clause for the query.
* @param string An optional limit clause for the query.
* @param boolean An option to quote incoming values of the array.

	 * @param string $table The table name to perform the query on.
* @param array $array An array of fields and their values.
* @param string $where An optional where clause for the query.
* @param string $limit An optional limit clause for the query.
* @param boolean $no_quote An option to quote incoming values of the array.

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

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

Zeile 868Zeile 900
		if(!is_array($array))
{
return false;

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

		}


		}


		$comma = "";
$query = "";
$quote = "'";

		$comma = "";
$query = "";
$quote = "'";

Zeile 877Zeile 909
		if($no_quote == true)
{
$quote = "";

		if($no_quote == true)
{
$quote = "";

		}

		}


foreach($array as $field => $value)
{


foreach($array as $field => $value)
{

Zeile 915Zeile 947
		");
}


		");
}


 
	/**
* @param int|string $value
* @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 932Zeile 970
	/**
* Build a delete query.
*

	/**
* Build a delete query.
*

	 * @param string The table name to perform the query on.
* @param string An optional where clause for the query.
* @param string An optional limit clause for the query.

	 * @param string $table The table name to perform the query on.
* @param string $where An optional where clause for the query.
* @param string $limit An optional limit clause for the query.

	 * @return resource The query data.
*/
function delete_query($table, $where="", $limit="")

	 * @return resource The query data.
*/
function delete_query($table, $where="", $limit="")

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

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

	 * @param string The string to be escaped.

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

	 * @return string The escaped string.
*/
function escape_string($string)

	 * @return string The escaped string.
*/
function escape_string($string)

Zeile 988Zeile 1026
	/**
* Frees the resources of a MySQLi query.
*

	/**
* Frees the resources of a MySQLi query.
*

	 * @param object The query to destroy.

	 * @param resource $query The query to destroy.

	 * @return boolean Returns true on success, false on faliure
*/
function free_result($query)

	 * @return boolean Returns true on success, false on faliure
*/
function free_result($query)

Zeile 999Zeile 1037
	/**
* Escape a string used within a like command.
*

	/**
* Escape a string used within a like command.
*

	 * @param string The string to be escaped.

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

	 * @return string The escaped string.
*/
function escape_string_like($string)
{

	 * @return string The escaped 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 1019Zeile 1057
			return $this->version;
}


			return $this->version;
}


		$version = @mysql_get_server_info();
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 1038Zeile 1072
	/**
* Optimizes a specific table.
*

	/**
* Optimizes a specific table.
*

	 * @param string The name of the table to be optimized.

	 * @param string $table The name of the table to be optimized.

	 */
function optimize_table($table)
{

	 */
function optimize_table($table)
{

Zeile 1048Zeile 1082
	/**
* Analyzes a specific table.
*

	/**
* Analyzes a specific table.
*

	 * @param string The name of the table to be analyzed.

	 * @param string $table The name of the table to be analyzed.

	 */
function analyze_table($table)
{

	 */
function analyze_table($table)
{

Zeile 1058Zeile 1092
	/**
* Show the "create table" command for a specific table.
*

	/**
* Show the "create table" command for a specific table.
*

	 * @param string The name of the table.

	 * @param string $table The name of the table.

	 * @return string The MySQL command to create the specified table.

	 * @return string The MySQL command to create the specified table.

	 */

	 */

	function show_create_table($table)
{
$query = $this->write_query("SHOW CREATE TABLE {$this->table_prefix}{$table}");

	function show_create_table($table)
{
$query = $this->write_query("SHOW CREATE TABLE {$this->table_prefix}{$table}");

Zeile 1071Zeile 1105
	/**
* Show the "show fields from" command for a specific table.
*

	/**
* Show the "show fields from" command for a specific table.
*

	 * @param string The name of the table.
* @return string Field info for that table

	 * @param string $table The name of the table.
* @return array Field info for that table

	 */
function show_fields_from($table)
{
$query = $this->write_query("SHOW FIELDS FROM {$this->table_prefix}{$table}");

	 */
function show_fields_from($table)
{
$query = $this->write_query("SHOW FIELDS FROM {$this->table_prefix}{$table}");

 
		$field_info = array();

		while($field = $this->fetch_array($query))

		while($field = $this->fetch_array($query))

		{

		{

			$field_info[] = $field;
}
return $field_info;

			$field_info[] = $field;
}
return $field_info;

Zeile 1087Zeile 1122
	/**
* Returns whether or not the table contains a fulltext index.
*

	/**
* Returns whether or not the table contains a fulltext index.
*

	 * @param string The name of the table.
* @param string Optionally specify the name of the index.

	 * @param string $table The name of the table.
* @param string $index Optionally specify the name of the index.

	 * @return boolean True or false if the table has a fulltext index or not.
*/
function is_fulltext($table, $index="")

	 * @return boolean True or false if the table has a fulltext index or not.
*/
function is_fulltext($table, $index="")

Zeile 1106Zeile 1141
			}
}
if(preg_match('#FULLTEXT KEY#i', $structure))

			}
}
if(preg_match('#FULLTEXT KEY#i', $structure))

		{
return true;
}
return false;
}

/**

		{
return true;
}
return false;
}

/**

	 * Returns whether or not this database engine supports fulltext indexing.
*

	 * Returns whether or not this database engine supports fulltext indexing.
*

	 * @param string The table to be checked.

	 * @param string $table The table to be checked.

	 * @return boolean True or false if supported or not.
*/


	 * @return boolean True or false if supported or not.
*/


Zeile 1129Zeile 1164
			$table_type = my_strtoupper($status['Engine']);
}
else

			$table_type = my_strtoupper($status['Engine']);
}
else

		{

		{

			$table_type = my_strtoupper($status['Type']);
}
if(version_compare($version, '3.23.23', '>=') && ($table_type == 'MYISAM' || $table_type == 'ARIA'))

			$table_type = my_strtoupper($status['Type']);
}
if(version_compare($version, '3.23.23', '>=') && ($table_type == 'MYISAM' || $table_type == 'ARIA'))

Zeile 1146Zeile 1181
	/**
* Checks to see if an index exists on a specified table
*

	/**
* Checks to see if an index exists on a specified table
*

	 * @param string The name of the table.
* @param string The name of the index.


	 * @param string $table The name of the table.
* @param string $index The name of the index.
* @return bool Whether or not the index exists in that table

	 */
function index_exists($table, $index)
{

	 */
function index_exists($table, $index)
{

Zeile 1163Zeile 1199
		}

if($index_exists)

		}

if($index_exists)

		{
return true;
}

return false;
}

/**

		{
return true;
}

return false;
}

/**

	 * Returns whether or not this database engine supports boolean fulltext matching.
*

	 * Returns whether or not this database engine supports boolean fulltext matching.
*

	 * @param string The table to be checked.

	 * @param string $table The table to be checked.

	 * @return boolean True or false if supported or not.
*/
function supports_fulltext_boolean($table)

	 * @return boolean True or false if supported or not.
*/
function supports_fulltext_boolean($table)

Zeile 1189Zeile 1225

/**
* Creates a fulltext index on the specified column in the specified table with optional index name.


/**
* Creates a fulltext index on the specified column in the specified table with optional index name.

	 *
* @param string The name of the table.
* @param string Name of the column to be indexed.
* @param string The index name, optional.
*/

	 *
* @param string $table The name of the table.
* @param string $column Name of the column to be indexed.
* @param string $name The index name, optional.
*/

	function create_fulltext_index($table, $column, $name="")
{
$this->write_query("

	function create_fulltext_index($table, $column, $name="")
{
$this->write_query("

Zeile 1205Zeile 1241
	/**
* Drop an index with the specified name from the specified table
*

	/**
* Drop an index with the specified name from the specified table
*

	 * @param string The name of the table.
* @param string The name of the index.

	 * @param string $table The name of the table.
* @param string $name The name of the index.

	 */
function drop_index($table, $name)
{

	 */
function drop_index($table, $name)
{

Zeile 1219Zeile 1255
	/**
* Drop an table with the specified table
*

	/**
* Drop an table with the specified table
*

	 * @param boolean hard drop - no checking
* @param boolean use table prefix


	 * @param string $table The table to drop
* @param boolean $hard hard drop - no checking
* @param boolean $table_prefix use table prefix

	 */
function drop_table($table, $hard=false, $table_prefix=true)

	 */
function drop_table($table, $hard=false, $table_prefix=true)

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

if($hard == false)

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

		{
$this->write_query('DROP TABLE IF EXISTS '.$table_prefix.$table);
}

Zeile 1246Zeile 1283
	/**
* Renames a table
*

	/**
* Renames a table
*

	 * @param string The old table name
* @param string the new table name
* @param boolean use table prefix


	 * @param string $old_table The old table name
* @param string $new_table the new table name
* @param boolean $table_prefix use table prefix
* @return resource

	 */
function rename_table($old_table, $new_table, $table_prefix=true)
{

	 */
function rename_table($old_table, $new_table, $table_prefix=true)
{

Zeile 1267Zeile 1305
	/**
* Replace contents of table with values
*

	/**
* Replace contents of table with values
*

	 * @param string The table
* @param array 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 resource|bool

	 */

	 */

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

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

	{
global $mybb;


	{
global $mybb;


Zeile 1293Zeile 1334
			}

$comma = ',';

			}

$comma = ',';

		}


		}


		if(empty($replacements))
{
return false;

		if(empty($replacements))
{
return false;

Zeile 1306Zeile 1347
	/**
* Drops a column
*

	/**
* Drops a column
*

	 * @param string The table
* @param string The column name


	 * @param string $table The table
* @param string $column The column name
* @return resource

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

	}

/**
* Adds a column
*

	 * @param string The table
* @param string The column name
* @param string the new column definition


	 * @param string $table The table
* @param string $column The column name
* @param string $definition the new column definition
* @return resource

	 */
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 The table
* @param string The column name
* @param string the new column definition
*/
function modify_column($table, $column, $new_definition)
{
return $this->write_query("ALTER TABLE {$this->table_prefix}{$table} MODIFY {$column} {$new_definition}");
}































	 *
* @param string $table The table
* @param string $column The column name
* @param string $new_definition the new column definition
* @param boolean|string $new_not_null Whether to "drop" or "set" the NOT NULL attribute (no change if false)
* @param boolean|string $new_default_value The new default value, or false to drop the attribute
* @return bool Returns true if all queries are executed successfully or false if one of them failed
*/
function modify_column($table, $column, $new_definition, $new_not_null=false, $new_default_value=false)
{
$column = trim($column, '`');

if($new_not_null !== false)
{
if(strtolower($new_not_null) == "set")
{
$not_null = "NOT NULL";
}
else
{
$not_null = "NULL";
}
}
else
{
$not_null = '';
}

if($new_default_value !== false)
{
$default = "DEFAULT ".$new_default_value;
}
else
{
$default = '';
}

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


/**
* Renames a column
*


/**
* Renames a column
*

	 * @param string The table
* @param string The old column name
* @param string the new column name
* @param string the new column definition




	 * @param string $table The table
* @param string $old_column The old column name
* @param string $new_column the new column name
* @param string $new_definition the new column definition
* @param boolean|string $new_not_null Whether to "drop" or "set" the NOT NULL attribute (no change if false)
* @param boolean|string $new_default_value The new default value, or false to drop the attribute
* @return bool Returns true if all queries are executed successfully

	 */

	 */

	function rename_column($table, $old_column, $new_column, $new_definition)

	function rename_column($table, $old_column, $new_column, $new_definition, $new_not_null=false, $new_default_value=false)

	{

	{

		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, '`');

if($new_not_null !== false)
{
if(strtolower($new_not_null) == "set")
{
$not_null = "NOT NULL";
}
else
{
$not_null = "NULL";
}
}
else
{
$not_null = '';
}

if($new_default_value !== false)
{
$default = "DEFAULT ".$new_default_value;
}
else
{
$default = '';
}

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

	}

/**
* Sets the table prefix used by the simple select, insert, update and delete functions
*

	}

/**
* Sets the table prefix used by the simple select, insert, update and delete functions
*

	 * @param string The new table prefix

	 * @param string $prefix The new table prefix

	 */
function set_table_prefix($prefix)
{

	 */
function set_table_prefix($prefix)
{

Zeile 1364Zeile 1472
	/**
* Fetched the total size of all mysql tables or a specific table
*

	/**
* Fetched the total size of all mysql tables or a specific table
*

	 * @param string The table (optional)

	 * @param string $table The table (optional)

	 * @return integer the total size of all mysql tables or a specific table
*/
function fetch_size($table='')

	 * @return integer the total size of all mysql tables or a specific table
*/
function fetch_size($table='')

Zeile 1388Zeile 1496
	/**
* Fetch a list of database character sets this DBMS supports
*

	/**
* Fetch a list of database character sets this DBMS supports
*

	 * @return array Array of supported character sets with array key being the name, array value being display name. False if unsupported

	 * @return array|bool Array of supported character sets with array key being the name, array value being display name. False if unsupported

	 */
function fetch_db_charsets()
{

	 */
function fetch_db_charsets()
{

Zeile 1402Zeile 1510
			'cp850' => 'DOS West European',
'hp8' => 'HP West European',
'koi8r' => 'KOI8-R Relcom Russian',

			'cp850' => 'DOS West European',
'hp8' => 'HP West European',
'koi8r' => 'KOI8-R Relcom Russian',

			'latin1' => 'cp1252 West European',

			'latin1' => 'ISO 8859-1 Latin 1',

			'latin2' => 'ISO 8859-2 Central European',
'swe7' => '7bit Swedish',
'ascii' => 'US ASCII',

			'latin2' => 'ISO 8859-2 Central European',
'swe7' => '7bit Swedish',
'ascii' => 'US ASCII',

Zeile 1430Zeile 1538
			'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 1440Zeile 1547
	/**
* Fetch a database collation for a particular database character set
*

	/**
* Fetch a database collation for a particular database character set
*

	 * @param string The database character set
* @return string The matching database collation, false if unsupported

	 * @param string  $charset The database character set
* @return string|bool The matching database collation, false if unsupported

	 */
function fetch_charset_collation($charset)
{

	 */
function fetch_charset_collation($charset)
{

Zeile 1479Zeile 1586
			'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',

Zeile 1524Zeile 1630
	/**
* Binary database fields require special attention.
*

	/**
* Binary database fields require special attention.
*

	 * @param string Binary value

	 * @param string $string Binary value

	 * @return string Encoded binary value
*/
function escape_binary($string)

	 * @return string Encoded binary value
*/
function escape_binary($string)

Zeile 1535Zeile 1641
	/**
* Unescape binary data.
*

	/**
* Unescape binary data.
*

	 * @param string Binary value

	 * @param string $string Binary value

	 * @return string Encoded binary value
*/
function unescape_binary($string)

	 * @return string Encoded binary value
*/
function unescape_binary($string)