Vergleich inc/db_mysql.php - 1.8.9 - 1.8.28

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 191Zeile 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 485Zeile 485
		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 710Zeile 714
	 * @param string $field The field name.
* @param string $table The table name.
* @return boolean True when exists, false if not.

	 * @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)
{
$query = $this->write_query("

	function field_exists($field, $table)
{
$query = $this->write_query("

Zeile 722Zeile 726
		if($exists > 0)
{
return true;

		if($exists > 0)
{
return true;

		}
else

		}
else

		{
return false;
}

		{
return false;
}

Zeile 820Zeile 824
			else
{
$array[$field] = $this->quote_val($value);

			else
{
$array[$field] = $this->quote_val($value);

			}
}


			}
}


		$fields = "`".implode("`,`", array_keys($array))."`";
$values = implode(",", $array);
$this->write_query("

		$fields = "`".implode("`,`", array_keys($array))."`";
$values = implode(",", $array);
$this->write_query("

Zeile 831Zeile 835
			VALUES (".$values.")
");
return $this->insert_id();

			VALUES (".$values.")
");
return $this->insert_id();

	}

/**

	}

/**

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

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

Zeile 847Zeile 851
		if(!is_array($array))
{
return;

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

		}

		}


// Field names
$fields = array_keys($array[0]);


// Field names
$fields = array_keys($array[0]);

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

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

		}


		}


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

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

Zeile 929Zeile 933
				$query .= $comma."`".$field."`={$quoted_val}";
}
$comma = ', ';

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

		}

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

		}

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


if(!empty($limit))
{


if(!empty($limit))
{

Zeile 962Zeile 966
		else
{
$quoted = $quote . $value . $quote;

		else
{
$quoted = $quote . $value . $quote;

		}

		}


return $quoted;
}


return $quoted;
}

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

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

	{

	{

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

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

Zeile 1004Zeile 1008
	function escape_string($string)
{
if($this->db_encoding == 'utf8')

	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, false);
}
elseif($this->db_encoding == 'utf8mb4')

Zeile 1032Zeile 1036
	function free_result($query)
{
return mysql_free_result($query);

	function free_result($query)
{
return mysql_free_result($query);

	}

/**

	}

/**

	 * Escape a string used within a like command.
*
* @param string $string The string to be escaped.

	 * Escape a string used within a like command.
*
* @param string $string The string to be escaped.

Zeile 1042Zeile 1046
	 */
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));

	}

/**
* Gets the current version of MySQL.

	}

/**
* Gets the current version of MySQL.

	 *

	 *

	 * @return string Version of MySQL.
*/
function get_version()
{
if($this->version)

	 * @return string Version of MySQL.
*/
function get_version()
{
if($this->version)

		{

		{

			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 1081Zeile 1081
	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 1095Zeile 1095

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


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

	 *

	 *

	 * @param string $table The name of the table.
* @return string The MySQL command to create the specified table.
*/

	 * @param string $table The name of the table.
* @return string The MySQL command to create the specified table.
*/

Zeile 1108Zeile 1108

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


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

	 *

	 *

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

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

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

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

	}


	}


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

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

Zeile 1136Zeile 1136
		if($index != "")
{
if(preg_match("#FULLTEXT KEY (`?)$index(`?)#i", $structure))

		if($index != "")
{
if(preg_match("#FULLTEXT KEY (`?)$index(`?)#i", $structure))

			{

			{

				return true;
}
else

				return true;
}
else

Zeile 1150Zeile 1150
		}
return false;
}

		}
return false;
}





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

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

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

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

		{

		{

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

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

		}

		}

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

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

		}

		}

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

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

			return true;
}
return false;

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

	 * @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)
{
$index_exists = false;

	function index_exists($table, $index)
{
$index_exists = false;

Zeile 1200Zeile 1200
				$index_exists = true;
break;
}

				$index_exists = true;
break;
}

		}


		}


		if($index_exists)
{
return true;

		if($index_exists)
{
return true;

Zeile 1225Zeile 1225
			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 1264
	 * @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($hard == false)
{
$this->write_query('DROP TABLE IF EXISTS '.$table_prefix.$table);

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

		}
else
{

		}
else
{

Zeile 1290Zeile 1290
	 * @param string $old_table The old table name
* @param string $new_table the new table name
* @param boolean $table_prefix 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

	 * @return resource

	 */
function rename_table($old_table, $new_table, $table_prefix=true)
{
if($table_prefix == false)
{
$table_prefix = "";

	 */
function rename_table($old_table, $new_table, $table_prefix=true)
{
if($table_prefix == false)
{
$table_prefix = "";

		}

		}

		else
{
$table_prefix = $this->table_prefix;
}

return $this->write_query("RENAME TABLE {$table_prefix}{$old_table} TO {$table_prefix}{$new_table}");

		else
{
$table_prefix = $this->table_prefix;
}

return $this->write_query("RENAME TABLE {$table_prefix}{$old_table} TO {$table_prefix}{$new_table}");

	}

	}


/**
* Replace contents of table with values
*
* @param string $table The table
* @param array $replacements The replacements


/**
* Replace contents of table with values
*
* @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 1333Zeile 1335
			else
{
$values .= $comma."`".$column."`=".$this->quote_val($value);

			else
{
$values .= $comma."`".$column."`=".$this->quote_val($value);

			}

			}


$comma = ',';
}


$comma = ',';
}

Zeile 1355Zeile 1357
	 */
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 $table The table
* @param string $column The column name

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

	 * @param string $definition the new 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}");

	}

/**

	}

/**

Zeile 1376Zeile 1382
	 *
* @param string $table The table
* @param string $column The column name

	 *
* @param string $table The table
* @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 1426
	 * @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}");

	}

/**

	}

/**