Vergleich inc/db_mysqli.php - 1.8.6 - 1.8.9

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

	 * @var mysqli
*/
public $current_link;

 

/**
* The database name.
*
* @var string
*/
public $database;


/**
* Explanation of a query.


/**
* Explanation of a query.

Zeile 82Zeile 89

/**
* The current version of MySQL.


/**
* The current version of MySQL.

	 *
* @var string

	 *
* @var string

	 */
public $version;


	 */
public $version;


Zeile 100Zeile 107
	 * @var string
*/
public $table_prefix;

	 * @var string
*/
public $table_prefix;


/**


/**

	 * The extension used to run the SQL database
*
* @var string

	 * The extension used to run the SQL database
*
* @var string

Zeile 110Zeile 117

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


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

	 *

	 *

	 * @var boolean
*/
public $can_search = true;

	 * @var boolean
*/
public $can_search = true;

Zeile 119Zeile 126
	 * The database encoding currently in use (if supported)
*
* @var string

	 * The database encoding currently in use (if supported)
*
* @var string

	 */

	 */

	public $db_encoding = "utf8";

/**

	public $db_encoding = "utf8";

/**

Zeile 128Zeile 135
	 * @var float
*/
public $query_time = 0;

	 * @var float
*/
public $query_time = 0;





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

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

Zeile 146Zeile 153
	{
// Simple connection to one server
if(array_key_exists('hostname', $config))

	{
// Simple connection to one server
if(array_key_exists('hostname', $config))

		{

		{

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

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

Zeile 154Zeile 161
		{
// Specified multiple servers, but no specific read/write servers
if(!array_key_exists('read', $config))

		{
// Specified multiple servers, but no specific read/write servers
if(!array_key_exists('read', $config))

			{

			{

				foreach($config as $key => $settings)
{
if(is_int($key))

				foreach($config as $key => $settings)
{
if(is_int($key))

Zeile 181Zeile 188
			}

if(array_key_exists('hostname', $connections[$type]))

			}

if(array_key_exists('hostname', $connections[$type]))

			{

			{

				$details = $connections[$type];
unset($connections);
$connections[$type][] = $details;

				$details = $connections[$type];
unset($connections);
$connections[$type][] = $details;

Zeile 198Zeile 205
				if(!empty($single_connection['pconnect']) && version_compare(PHP_VERSION, '5.3.0', '>='))
{
$persist = 'p:';

				if(!empty($single_connection['pconnect']) && version_compare(PHP_VERSION, '5.3.0', '>='))
{
$persist = 'p:';

				}


				}


				$link = "{$type}_link";

get_execution_time();

				$link = "{$type}_link";

get_execution_time();

Zeile 218Zeile 225
				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();
$this->query_time += $time_spent;


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


Zeile 238Zeile 245

// 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)
{
$this->error("[READ] Unable to connect to MySQL server");


// Have no read connection?
if(!$this->read_link)
{
$this->error("[READ] Unable to connect to MySQL server");

			return false;
}

			return false;
}

		// No write?
else if(!$this->write_link)
{

		// No write?
else if(!$this->write_link)
{

Zeile 273Zeile 280
	 */
function select_db($database)
{

	 */
function select_db($database)
{

 
		$this->database = $database;


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

Zeile 292Zeile 301
			if($slave_success && count($this->connections) > 1)
{
@mysqli_set_charset($this->write_link, $this->db_encoding);

			if($slave_success && count($this->connections) > 1)
{
@mysqli_set_charset($this->write_link, $this->db_encoding);

			}

			}

		}
return $success;
}

		}
return $success;
}

Zeile 436Zeile 445

$this->querylist[$this->query_count]['query'] = $string;
$this->querylist[$this->query_count]['time'] = $qtime;


$this->querylist[$this->query_count]['query'] = $string;
$this->querylist[$this->query_count]['time'] = $qtime;

	}

/**

	}

/**

	 * Return a result array for a query.
*
* @param mysqli_result $query The query data.

	 * Return a result array for a query.
*
* @param mysqli_result $query The query data.

Zeile 448Zeile 457
	function fetch_array($query, $resulttype=MYSQLI_ASSOC)
{
switch($resulttype)

	function fetch_array($query, $resulttype=MYSQLI_ASSOC)
{
switch($resulttype)

		{

		{

			case MYSQLI_NUM:
case MYSQLI_BOTH:

			case MYSQLI_NUM:
case MYSQLI_BOTH:

				break;

				break;

			default:
$resulttype = MYSQLI_ASSOC;
break;

			default:
$resulttype = MYSQLI_ASSOC;
break;

		}

$array = mysqli_fetch_array($query, $resulttype);

		}

$array = mysqli_fetch_array($query, $resulttype);


return $array;
}


return $array;
}

Zeile 493Zeile 502

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


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

	 *

	 *

	 * @param mysqli_result $query The query data.
* @return int The number of rows in the result.
*/

	 * @param mysqli_result $query The query data.
* @return int The number of rows in the result.
*/

Zeile 511Zeile 520
	{
$id = mysqli_insert_id($this->current_link);
return $id;

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

	}

	}


/**
* Close the connection with the DBMS.


/**
* Close the connection with the DBMS.

Zeile 632Zeile 641
	{
if($prefix)
{

	{
if($prefix)
{

			$query = $this->query("
SELECT `TABLE_NAME` FROM INFORMATION_SCHEMA.TABLES
WHERE `TABLE_SCHEMA` = '$database' AND `TABLE_TYPE` = 'BASE TABLE'
AND `TABLE_NAME` LIKE '".$this->escape_string($prefix)."%'
");
}
else
{
$query = $this->query("
SELECT `TABLE_NAME` FROM INFORMATION_SCHEMA.TABLES
WHERE `TABLE_SCHEMA` = '$database' AND `TABLE_TYPE` = 'BASE TABLE'
");
}








			if(version_compare($this->get_version(), '5.0.2', '>='))
{
$query = $this->query("SHOW FULL TABLES FROM `$database` WHERE table_type = 'BASE TABLE' AND `Tables_in_$database` LIKE '".$this->escape_string($prefix)."%'");
}
else
{
$query = $this->query("SHOW TABLES FROM `$database` LIKE '".$this->escape_string($prefix)."%'");
}
}
else
{
if(version_compare($this->get_version(), '5.0.2', '>='))
{
$query = $this->query("SHOW FULL TABLES FROM `$database` WHERE table_type = 'BASE TABLE'");
}
else
{
$query = $this->query("SHOW TABLES FROM `$database`");
}
}


$tables = array();
while(list($table) = mysqli_fetch_array($query))
{
$tables[] = $table;


$tables = array();
while(list($table) = mysqli_fetch_array($query))
{
$tables[] = $table;

		}


		}


		return $tables;
}

		return $tables;
}





	/**
* Check if a table exists in a database.
*

	/**
* Check if a table exists in a database.
*

Zeile 663Zeile 680
	function table_exists($table)
{
// Execute on master server to ensure if we've just created a table that we get the correct result

	function table_exists($table)
{
// Execute on master server to ensure if we've just created a table that we get the correct result

		$query = $this->write_query("
SELECT `TABLE_NAME` FROM INFORMATION_SCHEMA.TABLES
WHERE `TABLE_TYPE` = 'BASE TABLE'
AND `TABLE_NAME` LIKE '{$this->table_prefix}$table'
");
$exists = $this->num_rows($query);



		if(version_compare($this->get_version(), '5.0.2', '>='))
{
$query = $this->query("SHOW FULL TABLES FROM `".$this->database."` WHERE table_type = 'BASE TABLE' AND `Tables_in_".$this->database."` = '{$this->table_prefix}$table'");
}
else
{
$query = $this->query("SHOW TABLES LIKE '{$this->table_prefix}$table'");
}





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

		if($exists > 0)
{
return true;

		if($exists > 0)
{
return true;

Zeile 1438Zeile 1458
			'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 1487Zeile 1506
			'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',