Vergleich inc/db_mysql.php - 1.8.8 - 1.8.34

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

	 * @var resource
*/
public $current_link;

 

/**
* @var array
*/
public $connections = array();


/**
* The database name.


/**
* The database name.

	 *
* @var string

	 *
* @var string

	 */
public $database;

	 */
public $database;





	/**
* Explanation of a query.

	/**
* Explanation of a query.

	 *
* @var string
*/

	 *
* @var string
*/

	public $explain;

/**

	public $explain;

/**

Zeile 93Zeile 98
	 * @var string
*/
public $version;

	 * @var string
*/
public $version;


/**


/**

	 * The current table type in use (myisam/innodb)

	 * The current table type in use (myisam/innodb)

	 *
* @var string

	 *
* @var string

	 */
public $table_type = "myisam";

/**
* The table prefix used for simple select, update, insert and delete queries

	 */
public $table_type = "myisam";

/**
* The table prefix used for simple select, update, insert and delete queries

	 *
* @var string

	 *
* @var string

	 */
public $table_prefix;


	 */
public $table_prefix;


Zeile 114Zeile 119
	 * @var string
*/
public $engine = "mysql";

	 * @var string
*/
public $engine = "mysql";





	/**
* Weather or not this engine can use the search functionality

	/**
* Weather or not this engine can use the search functionality

	 *

	 *

	 * @var boolean
*/
public $can_search = true;

	 * @var boolean
*/
public $can_search = true;


/**


/**

	 * The database encoding currently in use (if supported)
*
* @var string

	 * The database encoding currently in use (if supported)
*
* @var string

Zeile 135Zeile 140
	 * @var float
*/
public $query_time = 0;

	 * @var float
*/
public $query_time = 0;





	/**
* Stores previous run query type: 1 => write; 0 => read
*

	/**
* Stores previous run query type: 1 => write; 0 => read
*

Zeile 175Zeile 180
			else
{
$connections = $config;

			else
{
$connections = $config;

			}
}

			}
}





		$this->db_encoding = $config['encoding'];




		if(isset($config['encoding']))
{
$this->db_encoding = $config['encoding'];
}


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


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

Zeile 191Zeile 199
			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 239Zeile 247
		if(!$this->read_link)
{
$this->error("[READ] Unable to connect to MySQL server");

		if(!$this->read_link)
{
$this->error("[READ] Unable to connect to MySQL server");

			return false;

			return false;

		}
// No write?
else if(!$this->write_link)

		}
// No write?
else if(!$this->write_link)

Zeile 485Zeile 493
		if($row === false)
{
$array = $this->fetch_array($query);

		if($row === false)
{
$array = $this->fetch_array($query);

			return $array[$field];





			if($array !== null)
{
return $array[$field];
}
return null;

		}
else
{

		}
else
{

Zeile 495Zeile 507

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


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

	 *
* @param resource $query The query ID.

	 *
* @param resource $query The query ID.

	 * @param int $row The pointer to move the row to.
* @return bool
*/

	 * @param int $row The pointer to move the row to.
* @return bool
*/

Zeile 514Zeile 526
	function num_rows($query)
{
return mysql_num_rows($query);

	function num_rows($query)
{
return mysql_num_rows($query);

	}

/**

	}

/**

	 * Return the last id number of inserted data.
*
* @return int The id number.

	 * Return the last id number of inserted data.
*
* @return int The id number.

Zeile 524Zeile 536
	function insert_id()
{
return mysql_insert_id($this->current_link);

	function insert_id()
{
return mysql_insert_id($this->current_link);

	}

/**

	}

/**

	 * Close the connection with the DBMS.
*
*/

	 * Close the connection with the DBMS.
*
*/

Zeile 536Zeile 548
		if($this->write_link)
{
@mysql_close($this->write_link);

		if($this->write_link)
{
@mysql_close($this->write_link);

		}

		}

	}

/**

	}

/**

Zeile 545Zeile 557
	 * @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 566Zeile 578
		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 603Zeile 615
			else
{
trigger_error("<strong>[SQL] [".$this->error_number()."] ".$this->error_string()."</strong><br />{$string}", E_USER_ERROR);

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

			}


			}


			return true;

			return true;

		}

		}

		else
{
return false;
}

		else
{
return false;
}

	}


	}


	/**
* Returns the number of affected rows in a query.
*
* @return int The number of affected rows.
*/
function affected_rows()

	/**
* Returns the number of affected rows in a query.
*
* @return int The number of affected rows.
*/
function affected_rows()

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

/**

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

/**

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

	 * 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 642Zeile 654
	 * @return array The table list.
*/
function list_tables($database, $prefix='')

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

	{

	{

		if($prefix)
{
if(version_compare($this->get_version(), '5.0.2', '>='))

		if($prefix)
{
if(version_compare($this->get_version(), '5.0.2', '>='))

Zeile 692Zeile 704
		{
$query = $this->query("SHOW TABLES LIKE '{$this->table_prefix}$table'");
}

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


$exists = $this->num_rows($query);
if($exists > 0)
{
return true;
}
else
{
return false;
}
}

/**


$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 720Zeile 732
		");
$exists = $this->num_rows($query);
if($exists > 0)

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

		{
return true;
}
else
{
return false;
}
}

/**

		{
return true;
}
else
{
return false;
}
}

/**

	 * Add a shutdown query.
*
* @param resource $query The query data.

	 * Add a shutdown query.
*
* @param resource $query The query data.

Zeile 1042Zeile 1054
	 */
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 1057Zeile 1069
			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)
{
$version = explode(".", $version, 3);
$this->version = (int)$version[0].".".(int)$version[1].".".(int)$version[2];
}
return $this->version;

		if($version)
{
$version = explode(".", $version, 3);
$this->version = (int)$version[0].".".(int)$version[1].".".(int)$version[2];
}
return $this->version;

	}


	}


	/**
* Optimizes a specific table.
*

	/**
* Optimizes a specific table.
*

Zeile 1085Zeile 1093

/**
* Analyzes a specific table.


/**
* Analyzes a specific table.

	 *

	 *

	 * @param string $table 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)

	{

	{

		$this->write_query("ANALYZE TABLE {$this->table_prefix}{$table}");

		$this->write_query("ANALYZE TABLE {$this->table_prefix}{$table}");

	}


	}


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

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

Zeile 1104Zeile 1112
		$query = $this->write_query("SHOW CREATE TABLE {$this->table_prefix}{$table}");
$structure = $this->fetch_array($query);
return $structure['Create Table'];

		$query = $this->write_query("SHOW CREATE TABLE {$this->table_prefix}{$table}");
$structure = $this->fetch_array($query);
return $structure['Create Table'];

	}


	}


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

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

Zeile 1125Zeile 1133

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


/**
* Returns whether or not the table contains a fulltext 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.

	 * @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.

Zeile 1138Zeile 1146
			if(preg_match("#FULLTEXT KEY (`?)$index(`?)#i", $structure))
{
return true;

			if(preg_match("#FULLTEXT KEY (`?)$index(`?)#i", $structure))
{
return true;

			}

			}

			else
{
return false;
}
}
if(preg_match('#FULLTEXT KEY#i', $structure))

			else
{
return false;
}
}
if(preg_match('#FULLTEXT KEY#i', $structure))

		{

		{

			return true;
}
return false;

			return true;
}
return false;

Zeile 1203Zeile 1211
		}

if($index_exists)

		}

if($index_exists)

		{
return true;
}

		{
return true;
}


return false;
}


return false;
}

Zeile 1225Zeile 1233
			return true;
}
return false;

			return true;
}
return false;

	}

	}


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

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

	{
if($table_prefix == false)
{

			$table_prefix = "";
}
else

			$table_prefix = "";
}
else

Zeile 1311Zeile 1319
	 *
* @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 resource|bool
*/

	 * @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 1348Zeile 1358

/**
* Drops a column


/**
* Drops a column

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

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

Zeile 1367Zeile 1379
	 * @return resource
*/
function add_column($table, $column, $definition)

	 * @return resource
*/
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 resource
*/
function modify_column($table, $column, $new_definition)
{
return $this->write_query("ALTER TABLE {$this->table_prefix}{$table} MODIFY {$column} {$new_definition}");
}






























	 * @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} {$default}");
}


/**
* Renames a column


/**
* Renames a column

Zeile 1391Zeile 1434
	 * @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 string $old_column The old column name
* @param string $new_column the new column name
* @param string $new_definition the new column definition

	 * @return resource



	 * @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}");

	}

/**

	}

/**

Zeile 1477Zeile 1550
			'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 1526Zeile 1598
			'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',