Vergleich inc/db_mysqli.php - 1.8.18 - 1.8.37

  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;

/**

Zeile 86Zeile 91
	 * @var string
*/
public $explain;

	 * @var string
*/
public $explain;





	/**
* The current version of MySQL.
*

	/**
* The current version of MySQL.
*

Zeile 110Zeile 115

/**
* The extension used to run the SQL database


/**
* The extension used to run the SQL database

	 *
* @var string
*/

	 *
* @var string
*/

	public $engine = "mysqli";

/**

	public $engine = "mysqli";

/**

Zeile 138Zeile 143

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


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

	 *

	 *

	 * @var int
*/
protected $last_query_type = 0;

	 * @var int
*/
protected $last_query_type = 0;

Zeile 177Zeile 182
			}
}


			}
}


		$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 190Zeile 198
			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 493
			$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 525

/**
* 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 532Zeile 544
		if($this->write_link)
{
@mysqli_close($this->write_link);

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

		}

		}

	}

/**

	}

/**

Zeile 541Zeile 553
	 * @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 mysqli_errno($this->current_link);
}

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

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

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

		}
else
{

		}
else
{

			return mysqli_connect_error();
}
}

			return mysqli_connect_error();
}
}

Zeile 889Zeile 901
	 * @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.

	 * @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 mysqli_result The query data.
*/

	 * @return mysqli_result The query data.
*/

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

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

Zeile 929Zeile 941
			$comma = ', ';
}


			$comma = ', ';
}


		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 989Zeile 1001

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


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

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

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

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

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

Zeile 1032Zeile 1044
	 *
* @param string $string The string to be escaped.
* @return string The escaped string.

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

	 */

	 */

	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 1053Zeile 1065
		$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 1074Zeile 1086

/**
* Analyzes a specific table.


/**
* Analyzes a specific table.

	 *

	 *

	 * @param string $table The name of the table to be analyzed.
*/
function analyze_table($table)

	 * @param string $table The name of the table to be analyzed.
*/
function analyze_table($table)

Zeile 1094Zeile 1106
		$structure = $this->fetch_array($query);

return $structure['Create 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 1115Zeile 1127

/**
* 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 1128Zeile 1140
			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;
}





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

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

Zeile 1155Zeile 1167
		$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;
}
elseif(version_compare($version, '5.6', '>=') && $table_type == 'INNODB')

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

Zeile 1176Zeile 1188
		$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 1228
	 * @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 1318Zeile 1330
		}

if(empty($replacements))

		}

if(empty($replacements))

		{

		{

			 return false;
}


			 return false;
}


Zeile 1337Zeile 1349
		$column = trim($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 1360Zeile 1372
	 * @param string $table The table
* @param string $column The column name
* @param string $new_definition the new column definition

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

		$column = trim($column, '`');


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



























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 1376Zeile 1415
	 * @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)

	{
$old_column = trim($old_column, '`');
$new_column = trim($new_column, '`');


	{
$old_column = trim($old_column, '`');
$new_column = trim($new_column, '`');


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


























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

	}

/**

	}

/**