Vergleich inc/db_mysqli.php - 1.8.20 - 1.8.29

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 190Zeile 190
			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 485
			$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 509Zeile 513
	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 int The id number.

	 * Return the last id number of inserted data.
*
* @return int The id number.

Zeile 524Zeile 528

/**
* Close the connection with the DBMS.


/**
* Close the connection with the DBMS.

	 *
*/

	 *
*/

	function close()
{
@mysqli_close($this->read_link);

	function close()
{
@mysqli_close($this->read_link);

Zeile 539Zeile 543
	 * Return an error number.
*
* @return int The error number of the current error.

	 * Return an error number.
*
* @return int The error number of the current error.

	 */

	 */

	function error_number()
{
if($this->current_link)

	function error_number()
{
if($this->current_link)

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


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


Zeile 611Zeile 615

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


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

	 *

	 *

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

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

Zeile 653Zeile 657
		else
{
if(version_compare($this->get_version(), '5.0.2', '>='))

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

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


Zeile 681Zeile 685
	{
// Execute on master server to ensure if we've just created a table that we get the correct result
if(version_compare($this->get_version(), '5.0.2', '>='))

	{
// Execute on master server to ensure if we've just created a table that we get the correct result
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 FULL TABLES FROM `".$this->database."` WHERE table_type = 'BASE TABLE' AND `Tables_in_".$this->database."` = '{$this->table_prefix}$table'");
}
else

Zeile 708Zeile 712
	 * @return boolean True when exists, false if not.
*/
function field_exists($field, $table)

	 * @return boolean True when exists, false if not.
*/
function field_exists($field, $table)

	{

	{

		$query = $this->write_query("
SHOW COLUMNS
FROM {$this->table_prefix}$table

		$query = $this->write_query("
SHOW COLUMNS
FROM {$this->table_prefix}$table

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

if($exists > 0)

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

if($exists > 0)

		{

		{

			return true;

			return true;

		}
else
{

		}
else
{

			return false;
}
}

			return false;
}
}

Zeile 819Zeile 823
			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 830Zeile 834
			VALUES (".$values.")
");
return $this->insert_id();

			VALUES (".$values.")
");
return $this->insert_id();

	}

/**

	}

/**

	 * Build one query for multiple inserts from a multidimensional array.
*
* @param string $table The table name to perform the query on.

	 * Build one query for multiple inserts from a multidimensional array.
*
* @param string $table The table name to perform the query on.

Zeile 898Zeile 902
		if(!is_array($array))
{
return false;

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

		}


		}


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

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

Zeile 929Zeile 933
			$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 960Zeile 964
		else
{
$quoted = $quote . $value . $quote;

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

		}


		}


		return $quoted;
}


		return $quoted;
}


Zeile 1002Zeile 1006
		elseif($this->db_encoding == 'utf8mb4')
{
$string = validate_utf8_string($string);

		elseif($this->db_encoding == 'utf8mb4')
{
$string = validate_utf8_string($string);

		}

		}


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


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

Zeile 1035Zeile 1039
	 */
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 1044Zeile 1048
	 * @return string Version of MySQL.
*/
function get_version()

	 * @return string Version of MySQL.
*/
function get_version()

	{

	{

		if($this->version)

		if($this->version)

		{

		{

			return $this->version;
}


			return $this->version;
}


Zeile 1058Zeile 1062
		{
$version = explode(".", $version, 3);
$this->version = (int)$version[0].".".(int)$version[1].".".(int)$version[2];

		{
$version = explode(".", $version, 3);
$this->version = (int)$version[0].".".(int)$version[1].".".(int)$version[2];

		}

		}

		return $this->version;

		return $this->version;

	}

/**

	}

/**

	 * Optimizes a specific table.
*
* @param string $table The name of the table to be optimized.

	 * Optimizes a specific table.
*
* @param string $table The name of the table to be optimized.

Zeile 1070Zeile 1074
	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.
*
* @param string $table The name of the table to be analyzed.

	 * Analyzes a specific table.
*
* @param string $table The name of the table to be analyzed.

Zeile 1128Zeile 1132
			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;

Zeile 1155Zeile 1159
		$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 1267Zeile 1271
	 * @param string $old_table The old table name
* @param string $new_table the new table name
* @param boolean $table_prefix use table prefix

	 * @param string $old_table The old table name
* @param string $new_table the new table name
* @param boolean $table_prefix use table prefix

	 * @return mysqli_result

	 * @return mysqli_result

	 */
function rename_table($old_table, $new_table, $table_prefix=true)
{
if($table_prefix == false)
{
$table_prefix = "";

	 */
function rename_table($old_table, $new_table, $table_prefix=true)
{
if($table_prefix == false)
{
$table_prefix = "";

		}

		}

		else
{
$table_prefix = $this->table_prefix;
}

return $this->write_query("RENAME TABLE {$table_prefix}{$old_table} TO {$table_prefix}{$new_table}");

		else
{
$table_prefix = $this->table_prefix;
}

return $this->write_query("RENAME TABLE {$table_prefix}{$old_table} TO {$table_prefix}{$new_table}");

	}

	}


/**
* Replace contents of table with values


/**
* Replace contents of table with values

Zeile 1295Zeile 1299
	function replace_query($table, $replacements=array(), $default_field="", $insert_id=true)
{
global $mybb;

	function replace_query($table, $replacements=array(), $default_field="", $insert_id=true)
{
global $mybb;





		$values = '';
$comma = '';
foreach($replacements as $column => $value)

		$values = '';
$comma = '';
foreach($replacements as $column => $value)

Zeile 1308Zeile 1312
				}

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

				}

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

			}
else

			}
else

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

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





			$comma = ',';

			$comma = ',';

		}


		}


		if(empty($replacements))
{
return false;
}

return $this->write_query("REPLACE INTO {$this->table_prefix}{$table} SET {$values}");

		if(empty($replacements))
{
return false;
}

return $this->write_query("REPLACE INTO {$this->table_prefix}{$table} SET {$values}");

	}

	}


/**
* Drops a column


/**
* Drops a column

Zeile 1337Zeile 1341
		$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 1364
	 * @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



	 * @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)

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


	/**
* Renames a column
*

	/**
* Renames a column
*

Zeile 1376Zeile 1407
	 * @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}");

	}

/**

	}

/**