Vergleich inc/db_mysqli.php - 1.4.0 - 1.4.12

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 6Zeile 6
 * Website: http://www.mybboard.net
* License: http://www.mybboard.net/about/license
*

 * Website: http://www.mybboard.net
* License: http://www.mybboard.net/about/license
*

 * $Id: db_mysqli.php 3902 2008-06-11 02:21:37Z Tikitiki $

 * $Id: db_mysqli.php 4839 2010-03-29 23:52:54Z RyanGordon $

 */

class DB_MySQLi

 */

class DB_MySQLi

Zeile 143Zeile 143
		{
$connections['read'][] = $config;
}

		{
$connections['read'][] = $config;
}

 
		else

		// Connecting to more than one server
{
// Specified multiple servers, but no specific read/write servers
if(!array_key_exists('read', $config))

		// Connecting to more than one server
{
// Specified multiple servers, but no specific read/write servers
if(!array_key_exists('read', $config))

			{

			{

				foreach($config as $key => $settings)
{
if(is_int($key)) $connections['read'][] = $settings;

				foreach($config as $key => $settings)
{
if(is_int($key)) $connections['read'][] = $settings;

Zeile 157Zeile 158
			else
{
$connections = $config;

			else
{
$connections = $config;

			}
}

$this->db_encoding = $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 184Zeile 185
			foreach($connections[$type] as $single_connection)
{
$connect_function = "mysqli_connect";

			foreach($connections[$type] as $single_connection)
{
$connect_function = "mysqli_connect";

				if($single_connection['pconnect'])


				$persist = "";
if($single_connection['pconnect'] && version_compare(PHP_VERSION, '5.3.0', '>='))

				{

				{

					$connect_function = "mysqli_pconnect";

					$persist = "p:";

				}

$link = $type."_link";

				}

$link = $type."_link";

Zeile 196Zeile 198
				// Specified a custom port for this connection?
list($hostname, $port) = explode(":", $single_connection['hostname'], 2);
if($port)

				// Specified a custom port for this connection?
list($hostname, $port) = explode(":", $single_connection['hostname'], 2);
if($port)

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

				{
$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']);
}


$time_spent = $this->get_execution_time();
$this->query_time += $time_spent;


$time_spent = $this->get_execution_time();
$this->query_time += $time_spent;

Zeile 217Zeile 219
				{
$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>";
}

			}

			}

		}

// No write server was specified (simple connection or just multiple servers) - mirror write link
if(!array_key_exists('write', $connections))

		}

// No write server was specified (simple connection or just multiple servers) - mirror write link
if(!array_key_exists('write', $connections))

		{

		{

			$this->write_link = &$this->read_link;

			$this->write_link = &$this->read_link;

		}

		}


// Have no read connection?
if(!$this->read_link)


// Have no read connection?
if(!$this->read_link)

Zeile 235Zeile 237
		else if(!$this->write_link)
{
$this->error("[WRITE] Unable to connect to MySQL server");

		else if(!$this->write_link)
{
$this->error("[WRITE] Unable to connect to MySQL server");

		}

		}


// Select databases


// Select databases

		$this->select_db($config['database']);





		if(!$this->select_db($config['database']))
{
return false;
}


		$this->current_link = &$this->read_link;
return $this->read_link;
}

		$this->current_link = &$this->read_link;
return $this->read_link;
}

Zeile 253Zeile 258
	function select_db($database)
{
global $mybb;

	function select_db($database)
{
global $mybb;

		

		

		$master_success = @mysqli_select_db($this->read_link, $database) or $this->error("[READ] Unable to select database", $this->read_link);
if($this->write_link)
{

		$master_success = @mysqli_select_db($this->read_link, $database) or $this->error("[READ] Unable to select database", $this->read_link);
if($this->write_link)
{

			$slave_success = @mysqli_select_db($this->write_link, $database) or $this->error("[WRITE] Unable to slave database", $this->write_link);

			$slave_success = @mysqli_select_db($this->write_link, $database) or $this->error("[WRITE] Unable to select slave database", $this->write_link);

			
$success = ($master_success && $slave_success ? true : false);
}

			
$success = ($master_success && $slave_success ? true : false);
}

Zeile 289Zeile 294
	function query($string, $hide_errors=0, $write_query=0)
{
global $pagestarttime, $db, $mybb;

	function query($string, $hide_errors=0, $write_query=0)
{
global $pagestarttime, $db, $mybb;





		$this->get_execution_time();

// Only execute write queries on slave server

		$this->get_execution_time();

// Only execute write queries on slave server

Zeile 430Zeile 435
	 * @param int The number of the row to fetch it from.
*/
function fetch_field($query, $field, $row=false)

	 * @param int The number of the row to fetch it from.
*/
function fetch_field($query, $field, $row=false)

	{

	{

		if($row !== false)
{
$this->data_seek($query, $row);

		if($row !== false)
{
$this->data_seek($query, $row);

Zeile 459Zeile 464
	function num_rows($query)
{
return mysqli_num_rows($query);

	function num_rows($query)
{
return mysqli_num_rows($query);

	}


	}


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

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

Zeile 474Zeile 479

/**
* Close the connection with the DBMS.


/**
* Close the connection with the DBMS.

	 *

	 *

	 */
function close()
{
@mysqli_close($this->read_link);
if($this->write_link)
{

	 */
function close()
{
@mysqli_close($this->read_link);
if($this->write_link)
{

			@mysql_close($this->write_link);

			@mysqli_close($this->write_link);

		}
}


		}
}


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

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

 
		}
else
{
return false;

		}
}


		}
}


Zeile 713Zeile 722
		}

return $this->query($query);

		}

return $this->query($query);

	}

	}

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

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

Zeile 730Zeile 739
		}
$fields = "`".implode("`,`", array_keys($array))."`";
$values = implode("','", $array);

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

		$this->write_query("
INSERT

		$this->write_query("
INSERT

			INTO {$this->table_prefix}{$table} (".$fields.") 
VALUES ('".$values."')
");

			INTO {$this->table_prefix}{$table} (".$fields.") 
VALUES ('".$values."')
");

Zeile 746Zeile 755
	 * @return int The insert ID if available
*/
function insert_query_multiple($table, $array)

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

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

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

		}
// Field names
$fields = array_keys($array[0]);
$fields = "`".implode("`,`", $fields)."`";

		}
// Field names
$fields = array_keys($array[0]);
$fields = "`".implode("`,`", $fields)."`";





		$insert_rows = array();
foreach($array as $values)
{

		$insert_rows = array();
foreach($array as $values)
{

Zeile 766Zeile 775
			INSERT 
INTO {$this->table_prefix}{$table} ({$fields})
VALUES {$insert_rows}

			INSERT 
INTO {$this->table_prefix}{$table} ({$fields})
VALUES {$insert_rows}

		");

		");

	}

/**

	}

/**

Zeile 783Zeile 792
		if(!is_array($array))
{
return false;

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

		}


		}


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

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

		

		

		if($no_quote == true)

		if($no_quote == true)

		{

		{

			$quote = "";

			$quote = "";

		}

		}

		
foreach($array as $field => $value)
{

		
foreach($array as $field => $value)
{

Zeile 800Zeile 809
			$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 846Zeile 855
	 */
function escape_string($string)
{

	 */
function escape_string($string)
{

		if(function_exists("mysql_real_escape_string") && $this->read_link)

		if(function_exists("mysqli_real_escape_string") && $this->read_link)

		{
$string = mysqli_real_escape_string($this->read_link, $string);
}

		{
$string = mysqli_real_escape_string($this->read_link, $string);
}

Zeile 855Zeile 864
			$string = addslashes($string);
}
return $string;

			$string = addslashes($string);
}
return $string;

	}

	}

	
/**
* Frees the resources of a MySQLi query.

	
/**
* Frees the resources of a MySQLi query.

Zeile 889Zeile 898
		if($this->version)
{
return $this->version;

		if($this->version)
{
return $this->version;

		}

		}

		$query = $this->query("SELECT VERSION() as version");
$ver = $this->fetch_array($query);
if($ver['version'])

		$query = $this->query("SELECT VERSION() as version");
$ver = $this->fetch_array($query);
if($ver['version'])

Zeile 906Zeile 915
	 * @param string The name of the table to be optimized.
*/
function optimize_table($table)

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

	{

	{

		$this->write_query("OPTIMIZE TABLE ".$this->table_prefix.$table."");
}


		$this->write_query("OPTIMIZE TABLE ".$this->table_prefix.$table."");
}


Zeile 922Zeile 931

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


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

	 *
* @param string The name of the table.

	 *
* @param string The name of the table.

	 * @return string The MySQL command to create the specified table.
*/
function show_create_table($table)

	 * @return string The MySQL command to create the specified table.
*/
function show_create_table($table)

Zeile 972Zeile 981
			}
}
if(preg_match('#FULLTEXT KEY#i', $structure))

			}
}
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 992Zeile 1001
		$status = $this->fetch_array($query);
$table_type = my_strtoupper($status['Engine']);
if($version >= '3.23.23' && $table_type == 'MYISAM')

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

		{
return true;
}
return false;
}

		{
return true;
}
return false;
}


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


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

Zeile 1009Zeile 1018
		$version = $this->get_version();
$supports_fulltext = $this->supports_fulltext($table);
if($version >= '4.0.1' && $supports_fulltext == true)

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

		{
return true;
}

		{
return true;
}

		return false;
}


		return false;
}


Zeile 1021Zeile 1030
	 * @param string The name of the table.
* @param string Name of the column to be indexed.
* @param string The index name, optional.

	 * @param string The name of the table.
* @param string Name of the column to be indexed.
* @param string 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 1033Zeile 1042
	 * @param string The name of the table.
* @param string The name of the index.
*/

	 * @param string The name of the table.
* @param string The name of the index.
*/

	function drop_index($table, $name)












	function drop_index($table, $name)
{
$this->write_query("ALTER TABLE {$this->table_prefix}$table DROP INDEX $name");
}

/**
* Checks to see if an index exists on a specified table
*
* @param string The name of the table.
* @param string The name of the index.
*/
function index_exists($table, $index)

	{

	{

		$this->write_query("ALTER TABLE {$this->table_prefix}$table DROP INDEX $name");

















		$index_exists = false;
$query = $this->write_query("SHOW INDEX FROM {$this->table_prefix}{$table}");
while($ukey = $this->fetch_array($query))
{
if($ukey['Key_name'] == $index)
{
$index_exists = true;
break;
}
}

if($index_exists)
{
return true;
}

return false;

	}

/**

	}

/**

Zeile 1131Zeile 1167
	 */
function fetch_db_charsets()
{

	 */
function fetch_db_charsets()
{

		if($this_link && $this->get_version() < 4.1)

		if($this->link && version_compare($this->get_version(), "4.1", "<"))

		{
return false;
}

		{
return false;
}

Zeile 1277Zeile 1313
	}
}


	}
}


if(!class_exists('databaseEngine'))
{
class databaseEngine extends DB_MySQLi {
}
}

 
?>

?>