Vergleich inc/db_mysqli.php - 1.8.11 - 1.8.30

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 190Zeile 190
			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
			$this->data_seek($query, $row);
}
$array = $this->fetch_array($query);

			$this->data_seek($query, $row);
}
$array = $this->fetch_array($query);

		return $array[$field];





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

	}

/**

	}

/**

Zeile 498Zeile 502
	function data_seek($query, $row)
{
return mysqli_data_seek($query, $row);

	function data_seek($query, $row)
{
return mysqli_data_seek($query, $row);

	}


	}


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

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

Zeile 513Zeile 517

/**
* Return the last id number of inserted data.


/**
* Return the last id number of inserted data.

	 *

	 *

	 * @return int The id number.

	 * @return int The id number.

	 */

	 */

	function insert_id()
{
$id = mysqli_insert_id($this->current_link);

	function insert_id()
{
$id = mysqli_insert_id($this->current_link);

Zeile 527Zeile 531
	 *
*/
function close()

	 *
*/
function close()

	{

	{

		@mysqli_close($this->read_link);
if($this->write_link)
{

		@mysqli_close($this->read_link);
if($this->write_link)
{

Zeile 554Zeile 558

/**
* Return an error string.


/**
* Return an error string.

	 *

	 *

	 * @return string The explanation for the current error.
*/
function error_string()
{
if($this->current_link)

	 * @return string The explanation for the current error.
*/
function error_string()
{
if($this->current_link)

		{

		{

			return mysqli_error($this->current_link);
}
else

			return mysqli_error($this->current_link);
}
else

Zeile 568Zeile 572
			return mysqli_connect_error();
}
}

			return mysqli_connect_error();
}
}





	/**
* Output a database error.
*

	/**
* Output a database error.
*

Zeile 582Zeile 586
			if(class_exists("errorHandler"))
{
global $error_handler;

			if(class_exists("errorHandler"))
{
global $error_handler;





				if(!is_object($error_handler))
{
require_once MYBB_ROOT."inc/class_error.php";

				if(!is_object($error_handler))
{
require_once MYBB_ROOT."inc/class_error.php";

Zeile 595Zeile 599
					"query" => $string
);
$error_handler->error(MYBB_SQL, $error);

					"query" => $string
);
$error_handler->error(MYBB_SQL, $error);

			}

			}

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

Zeile 815Zeile 819
				}

$array[$field] = $value;

				}

$array[$field] = $value;

			}

			}

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

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

Zeile 840Zeile 844
	 * @return void
*/
function insert_query_multiple($table, $array)

	 * @return void
*/
function insert_query_multiple($table, $array)

	{
global $mybb;

if(!is_array($array))

	{
global $mybb;

if(!is_array($array))

		{
return;
}

		{
return;
}

Zeile 857Zeile 861
			foreach($values as $field => $value)
{
if(isset($mybb->binary_fields[$table][$field]) && $mybb->binary_fields[$table][$field])

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

				{

				{

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

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

Zeile 898Zeile 902
		if(!is_array($array))
{
return false;

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

		}

		}


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

if($no_quote == true)


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

if($no_quote == true)

		{

		{

			$quote = "";
}

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

			$quote = "";
}

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

			{

			{

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

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

Zeile 925Zeile 929
				$quoted_value = $this->quote_val($value, $quote);

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

				$quoted_value = $this->quote_val($value, $quote);

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

			}

			}

			$comma = ', ';

			$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

Zeile 952Zeile 956
	 * @return int|string
*/
private function quote_val($value, $quote="'")

	 * @return int|string
*/
private function quote_val($value, $quote="'")

	{

	{

		if(is_int($value))

		if(is_int($value))

		{

		{

			$quoted = $value;

			$quoted = $value;

		}

		}

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

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





		return $quoted;

		return $quoted;

	}

/**

	}

/**

	 * Build a delete query.
*
* @param string $table The table name to perform the query on.

	 * Build a delete query.
*
* @param string $table The table name to perform the query on.

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

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

		}

		}

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

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

Zeile 1020Zeile 1024
	 *
* @param mysqli_result $query The query to destroy.
* @return boolean Returns true

	 *
* @param mysqli_result $query The query to destroy.
* @return boolean Returns true

	 */

	 */

	function free_result($query)

	function free_result($query)

	{

	{

		mysqli_free_result($query);
return true; // Kept for compatibility reasons

		mysqli_free_result($query);
return true; // Kept for compatibility reasons

	}

	}


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


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

Zeile 1034Zeile 1038
	 * @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));
}


/**
* Gets the current version of MySQL.


/**
* Gets the current version of MySQL.

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

		if($this->version)
{
return $this->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 1115Zeile 1119

/**
* 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 1143Zeile 1147

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


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

	 *
* @param string $table The table to be checked.
* @return boolean True or false if supported or not.
*/

	 *
* @param string $table The table to be checked.
* @return boolean True or false if supported or not.
*/


function supports_fulltext($table)
{


function supports_fulltext($table)
{

Zeile 1155Zeile 1159
		$status = $this->fetch_array($query);
$table_type = my_strtoupper($status['Engine']);
if(version_compare($version, '3.23.23', '>=') && ($table_type == 'MYISAM' || $table_type == 'ARIA'))

		$status = $this->fetch_array($query);
$table_type = my_strtoupper($status['Engine']);
if(version_compare($version, '3.23.23', '>=') && ($table_type == 'MYISAM' || $table_type == 'ARIA'))

		{
return true;
}

		{
return true;
}

		elseif(version_compare($version, '5.6', '>=') && $table_type == 'INNODB')
{
return true;

		elseif(version_compare($version, '5.6', '>=') && $table_type == 'INNODB')
{
return true;

Zeile 1167Zeile 1171

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


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

	 *

	 *

	 * @param string $table The table to be checked.
* @return boolean True or false if supported or not.
*/

	 * @param string $table The table to be checked.
* @return boolean True or false if supported or not.
*/

Zeile 1176Zeile 1180
		$version = $this->get_version();
$supports_fulltext = $this->supports_fulltext($table);
if(version_compare($version, '4.0.1', '>=') && $supports_fulltext == true)

		$version = $this->get_version();
$supports_fulltext = $this->supports_fulltext($table);
if(version_compare($version, '4.0.1', '>=') && $supports_fulltext == true)

		{
return true;
}
return false;

		{
return true;
}
return false;

	}

/**

	}

/**

Zeile 1216Zeile 1220
	 * @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.

	 * @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("ALTER TABLE {$this->table_prefix}$table ADD FULLTEXT $name ($column)");

	function create_fulltext_index($table, $column, $name="")
{
$this->write_query("ALTER TABLE {$this->table_prefix}$table ADD FULLTEXT $name ($column)");

Zeile 1241Zeile 1245
	 * @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);
}
else
{

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

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

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

Zeile 1270Zeile 1274
	 * @return mysqli_result
*/
function rename_table($old_table, $new_table, $table_prefix=true)

	 * @return mysqli_result
*/
function rename_table($old_table, $new_table, $table_prefix=true)

	{

	{

		if($table_prefix == false)
{
$table_prefix = "";

		if($table_prefix == false)
{
$table_prefix = "";

Zeile 1288Zeile 1292
	 *
* @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 1325Zeile 1331

/**
* Drops a column


/**
* Drops a column

	 *
* @param string $table The table

	 *
* @param string $table The table

	 * @param string $column The column name
* @return mysqli_result
*/
function drop_column($table, $column)
{

	 * @param string $column The column name
* @return mysqli_result
*/
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}`");

	}

/**

	}

/**

Zeile 1345Zeile 1353
	 */
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}");

	}

/**

	}

/**

Zeile 1353Zeile 1363
	 *
* @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 mysqli_result
*/
function modify_column($table, $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)

	{

	{

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




























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

	}

/**

	}

/**

Zeile 1368Zeile 1407
	 * @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 mysqli_result



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

	}

/**

	}

/**