Vergleich inc/db_mysqli.php - 1.8.8 - 1.8.33

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

	 * @var mysqli
*/
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 = "mysqli";

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





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

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

Zeile 174Zeile 179
			else
{
$connections = $config;

			else
{
$connections = $config;

			}

			}

		}

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

		}

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

Zeile 190Zeile 195
			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 235Zeile 240
				{
$this->connections[] = "[".strtoupper($type)."] {$single_connection['username']}@{$single_connection['hostname']} (Connected in ".format_time_duration($time_spent).")";
break;

				{
$this->connections[] = "[".strtoupper($type)."] {$single_connection['username']}@{$single_connection['hostname']} (Connected in ".format_time_duration($time_spent).")";
break;

				}

				}

				else
{
$this->connections[] = "<span style=\"color: red\">[FAILED] [".strtoupper($type)."] {$single_connection['username']}@{$single_connection['hostname']}</span>";

				else
{
$this->connections[] = "<span style=\"color: red\">[FAILED] [".strtoupper($type)."] {$single_connection['username']}@{$single_connection['hostname']}</span>";

Zeile 485Zeile 490
			$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 513Zeile 522

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


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

	 *

	 *

	 * @return int The id number.
*/
function insert_id()
{
$id = mysqli_insert_id($this->current_link);
return $id;

	 * @return int The id number.
*/
function insert_id()
{
$id = mysqli_insert_id($this->current_link);
return $id;

	}

/**

	}

/**

	 * Close the connection with the DBMS.
*
*/

	 * Close the connection with the DBMS.
*
*/

Zeile 558Zeile 567
	 * @return string The explanation for the current error.
*/
function error_string()

	 * @return string The explanation for the current error.
*/
function error_string()

	{

	{

		if($this->current_link)
{
return mysqli_error($this->current_link);

		if($this->current_link)
{
return mysqli_error($this->current_link);

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

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

			}
else
{

			}
else
{

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

return true;

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

return true;

		}

		}

		else
{
return false;
}

		else
{
return false;
}

	}

	}


/**
* Returns the number of affected rows in a query.


/**
* Returns the number of affected rows in a query.

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

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

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

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


/**
* Return the number of fields.


/**
* Return the number of fields.

Zeile 717Zeile 726
		$exists = $this->num_rows($query);

if($exists > 0)

		$exists = $this->num_rows($query);

if($exists > 0)

		{
return true;
}

		{
return true;
}

		else
{
return false;

		else
{
return false;

Zeile 740Zeile 749
			$shutdown_queries[$name] = $query;
}
else

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

		{

		{

			$shutdown_queries[] = $query;
}
}

			$shutdown_queries[] = $query;
}
}

Zeile 780Zeile 789
		if(isset($options['limit_start']) && isset($options['limit']))
{
$query .= " LIMIT ".$options['limit_start'].", ".$options['limit'];

		if(isset($options['limit_start']) && isset($options['limit']))
{
$query .= " LIMIT ".$options['limit_start'].", ".$options['limit'];

		}

		}

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

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

Zeile 788Zeile 797

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


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





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

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

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

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

	{
global $mybb;

if(!is_array($array))

	{
global $mybb;

if(!is_array($array))

		{
return false;
}

		{
return false;
}

Zeile 808Zeile 817
		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])

			{

			{

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

$array[$field] = $value;

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

$array[$field] = $value;

			}

			}

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

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

		}

		}


$fields = "`".implode("`,`", array_keys($array))."`";
$values = implode(",", $array);


$fields = "`".implode("`,`", array_keys($array))."`";
$values = implode(",", $array);

Zeile 878Zeile 887
			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.
*

Zeile 894Zeile 903
	function update_query($table, $array, $where="", $limit="", $no_quote=false)
{
global $mybb;

	function update_query($table, $array, $where="", $limit="", $no_quote=false)
{
global $mybb;





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

$comma = "";

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

$comma = "";

		$query = "";

		$query = "";

		$quote = "'";

if($no_quote == true)

		$quote = "'";

if($no_quote == true)

Zeile 960Zeile 969
		else
{
$quoted = $quote . $value . $quote;

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

		}


		}


		return $quoted;
}


		return $quoted;
}


Zeile 981Zeile 990
			$query .= " WHERE $where";
}
if(!empty($limit))

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

		{

		{

			$query .= " LIMIT $limit";
}
return $this->write_query("DELETE FROM {$this->table_prefix}$table $query");

			$query .= " LIMIT $limit";
}
return $this->write_query("DELETE FROM {$this->table_prefix}$table $query");

Zeile 1035Zeile 1044
	 */
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.
*
* @return string Version of MySQL.

	}

/**
* Gets the current version of MySQL.
*
* @return string Version of MySQL.

	 */

	 */

	function get_version()
{
if($this->version)

	function get_version()
{
if($this->version)

		{

		{

			return $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 1292Zeile 1297
	 *
* @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 1336Zeile 1343
	 */
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 $definition the new column definition
* @return mysqli_result
*/
function add_column($table, $column, $definition)

	 * @param string $table The table
* @param string $column The column name
* @param string $definition the new column definition
* @return mysqli_result
*/
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
*/
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 1372Zeile 1412
	 * @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}");

	}

/**

	}

/**

Zeile 1458Zeile 1528
			'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 1507Zeile 1576
			'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',