Vergleich inc/db_mysql.php - 1.8.12 - 1.8.31

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

	 * @var resource
*/
public $current_link;

 

/**
* @var array
*/
public $connections = array();


/**
* The database name.


/**
* The database name.

Zeile 191Zeile 196
			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 490
		if($row === false)
{
$array = $this->fetch_array($query);

		if($row === false)
{
$array = $this->fetch_array($query);

			return $array[$field];





			if($array !== null)
{
return $array[$field];
}
return null;

		}
else
{

		}
else
{

Zeile 495Zeile 504

/**
* Moves internal row pointer to the next row


/**
* Moves internal row pointer to the next row

	 *
* @param resource $query The query ID.

	 *
* @param resource $query The query ID.

	 * @param int $row The pointer to move the row to.
* @return bool
*/

	 * @param int $row The pointer to move the row to.
* @return bool
*/

Zeile 514Zeile 523
	function num_rows($query)
{
return mysql_num_rows($query);

	function num_rows($query)
{
return mysql_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 533
	function insert_id()
{
return mysql_insert_id($this->current_link);

	function insert_id()
{
return mysql_insert_id($this->current_link);

	}

/**

	}

/**

	 * Close the connection with the DBMS.
*
*/

	 * Close the connection with the DBMS.
*
*/

Zeile 536Zeile 545
		if($this->write_link)
{
@mysql_close($this->write_link);

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

		}

		}

	}

/**

	}

/**

Zeile 545Zeile 554
	 * @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 @mysql_errno($this->current_link);
}

		{
return @mysql_errno($this->current_link);
}

Zeile 566Zeile 575
		if($this->current_link)
{
return @mysql_error($this->current_link);

		if($this->current_link)
{
return @mysql_error($this->current_link);

		}

		}

		else
{
return @mysql_error();

		else
{
return @mysql_error();

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

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

			}


			}


			return true;

			return true;

		}

		}

		else
{
return false;
}

		else
{
return false;
}

	}


	}


	/**
* Returns the number of affected rows in a query.
*
* @return int The number of affected rows.
*/
function affected_rows()

	/**
* Returns the number of affected rows in a query.
*
* @return int The number of affected rows.
*/
function affected_rows()

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

/**

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

/**

	 * Return the number of fields.
*
* @param resource $query The query ID.
* @return int The number of fields.

	 * Return the number of fields.
*
* @param resource $query The query ID.
* @return int The number of fields.

	 */

	 */

	function num_fields($query)
{
return mysql_num_fields($query);

	function num_fields($query)
{
return mysql_num_fields($query);

Zeile 642Zeile 651
	 * @return array The table list.
*/
function list_tables($database, $prefix='')

	 * @return array The table list.
*/
function list_tables($database, $prefix='')

	{

	{

		if($prefix)
{
if(version_compare($this->get_version(), '5.0.2', '>='))

		if($prefix)
{
if(version_compare($this->get_version(), '5.0.2', '>='))

Zeile 692Zeile 701
		{
$query = $this->query("SHOW TABLES LIKE '{$this->table_prefix}$table'");
}

		{
$query = $this->query("SHOW TABLES LIKE '{$this->table_prefix}$table'");
}


$exists = $this->num_rows($query);
if($exists > 0)
{
return true;
}
else
{
return false;
}
}

/**


$exists = $this->num_rows($query);
if($exists > 0)
{
return true;
}
else
{
return false;
}
}

/**

	 * Check if a field exists in a database.
*
* @param string $field The field name.

	 * Check if a field exists in a database.
*
* @param string $field The field name.

Zeile 720Zeile 729
		");
$exists = $this->num_rows($query);
if($exists > 0)

		");
$exists = $this->num_rows($query);
if($exists > 0)

		{
return true;
}
else
{
return false;
}
}

/**

		{
return true;
}
else
{
return false;
}
}

/**

	 * Add a shutdown query.
*
* @param resource $query The query data.

	 * Add a shutdown query.
*
* @param resource $query The query data.

Zeile 1042Zeile 1051
	 */
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 1221Zeile 1230
			return true;
}
return false;

			return true;
}
return false;

	}

	}


/**
* Creates a fulltext index on the specified column in the specified table with optional index name.


/**
* Creates a fulltext index on the specified column in the specified table with optional index name.

Zeile 1260Zeile 1269
	 * @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)
{

	{
if($table_prefix == false)
{

			$table_prefix = "";
}
else

			$table_prefix = "";
}
else

Zeile 1307Zeile 1316
	 *
* @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 resource|bool
*/

	 * @return resource|bool
*/

	function replace_query($table, $replacements=array())

	function replace_query($table, $replacements=array(), $default_field="", $insert_id=true)

	{
global $mybb;


	{
global $mybb;


Zeile 1344Zeile 1355

/**
* Drops a column


/**
* Drops a column

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

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

	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 1363Zeile 1376
	 * @return resource
*/
function add_column($table, $column, $definition)

	 * @return resource
*/
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 resource
*/
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 1387Zeile 1431
	 * @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 resource



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

	}

/**

	}

/**