Vergleich inc/db_mysqli.php - 1.8.9 - 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;





	/**
* 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'];




			}
}

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


// Actually connect to the specified servers
foreach(array('read', 'write') as $type)
{
if(!isset($connections[$type]) || !is_array($connections[$type]))


// Actually connect to the specified servers
foreach(array('read', 'write') as $type)
{
if(!isset($connections[$type]) || !is_array($connections[$type]))

			{

			{

				break;

				break;

			}

			}


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

// Shuffle the connections
shuffle($connections[$type]);

				$connections[$type][] = $details;
}

// Shuffle the connections
shuffle($connections[$type]);





			// Loop-de-loop
foreach($connections[$type] as $single_connection)
{

			// Loop-de-loop
foreach($connections[$type] as $single_connection)
{

Zeile 206Zeile 214
				{
$persist = 'p:';
}

				{
$persist = 'p:';
}





				$link = "{$type}_link";

get_execution_time();

				$link = "{$type}_link";

get_execution_time();

Zeile 216Zeile 224
				if(strstr($single_connection['hostname'],':'))
{
list($hostname, $port) = explode(":", $single_connection['hostname'], 2);

				if(strstr($single_connection['hostname'],':'))
{
list($hostname, $port) = explode(":", $single_connection['hostname'], 2);

				}

				}


if($port)
{
$this->$link = @$connect_function($persist.$hostname, $single_connection['username'], $single_connection['password'], "", $port);


if($port)
{
$this->$link = @$connect_function($persist.$hostname, $single_connection['username'], $single_connection['password'], "", $port);

				}
else
{
$this->$link = @$connect_function($persist.$single_connection['hostname'], $single_connection['username'], $single_connection['password']);

				}
else
{
$this->$link = @$connect_function($persist.$single_connection['hostname'], $single_connection['username'], $single_connection['password']);

				}

$time_spent = get_execution_time();

				}

$time_spent = get_execution_time();

Zeile 235Zeile 243
				{
$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

				}
else

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

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

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 718Zeile 730

if($exists > 0)
{


if($exists > 0)
{

			return true;
}
else
{

			return true;
}
else
{

			return false;
}
}

			return false;
}
}

Zeile 761Zeile 773
		if($conditions != "")
{
$query .= " WHERE ".$conditions;

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

		}

		}


if(isset($options['group_by']))
{


if(isset($options['group_by']))
{

Zeile 797Zeile 809
	 * @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 820Zeile 832
			{
$array[$field] = $this->quote_val($value);
}

			{
$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 878Zeile 890
			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.
*
* @param string $table The table name to perform the query on.

	 * Build an update query from an array.
*
* @param string $table The table name to perform the query on.

Zeile 1035Zeile 1047
	 */
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 1050Zeile 1062
			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)
{
$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 1082
	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 1113Zeile 1121
		while($field = $this->fetch_array($query))
{
$field_info[] = $field;

		while($field = $this->fetch_array($query))
{
$field_info[] = $field;

		}

		}

		return $field_info;
}


		return $field_info;
}


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

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

			}

			}

			else
{
return false;
}

			else
{
return false;
}

		}

		}

		if(preg_match('#FULLTEXT KEY#i', $structure))
{
return true;

		if(preg_match('#FULLTEXT KEY#i', $structure))
{
return true;

Zeile 1147Zeile 1155

/**
* 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)
{
$version = $this->get_version();

	function supports_fulltext($table)
{
$version = $this->get_version();

Zeile 1209Zeile 1217
		if($index_exists)
{
return true;

		if($index_exists)
{
return true;

		}

		}


return false;
}


return false;
}

Zeile 1245Zeile 1253
	 * @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 = "";
}

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

		else
{
$table_prefix = $this->table_prefix;

		else
{
$table_prefix = $this->table_prefix;

Zeile 1289Zeile 1297

/**
* Replace contents of table with values


/**
* Replace contents of table with values

	 *

	 *

	 * @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 1310Zeile 1320
				}

$values .= $comma."`".$column."`=".$value;

				}

$values .= $comma."`".$column."`=".$value;

			}

			}

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

$comma = ',';

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

$comma = ',';

		}

		}


if(empty($replacements))
{


if(empty($replacements))
{

Zeile 1329Zeile 1339

/**
* Drops a column


/**
* Drops a column

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

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

	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 1348Zeile 1360
	 * @return mysqli_result
*/
function add_column($table, $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)
{
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 1372Zeile 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)

	{

	{

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

	}

/**

	}

/**