Vergleich inc/db_pgsql.php - 1.8.6 - 1.8.26

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 194Zeile 194
			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 288Zeile 288
	{
global $mybb;


	{
global $mybb;


		$string = preg_replace("#LIMIT (\s*)([0-9]+),(\s*)([0-9]+)$#im", "LIMIT $4 OFFSET $2", trim($string));

		$string = preg_replace("#LIMIT (\s*)([0-9]+),(\s*)([0-9]+);?$#im", "LIMIT $4 OFFSET $2", trim($string));


$this->last_query = $string;



$this->last_query = $string;


Zeile 479Zeile 479
	 */
function insert_id()
{

	 */
function insert_id()
{

		$this->last_query = str_replace(array("\r", "\t"), '', $this->last_query);
$this->last_query = str_replace("\n", ' ', $this->last_query);
preg_match('#INSERT INTO ([a-zA-Z0-9_\-]+)#i', $this->last_query, $matches);

		preg_match('#INSERT\s+INTO\s+([a-zA-Z0-9_\-]+)#i', $this->last_query, $matches);




$table = $matches[1];



$table = $matches[1];


Zeile 964Zeile 962
	 */
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 1093Zeile 1091

$primary_key = array();
$primary_key_name = '';


$primary_key = array();
$primary_key_name = '';

 

$unique_keys = array();


// We do this in two steps. It makes placing the comma easier
while($row = $this->fetch_array($query))
{
if($row['primary_key'] == 't')


// We do this in two steps. It makes placing the comma easier
while($row = $this->fetch_array($query))
{
if($row['primary_key'] == 't')

			{

			{

				$primary_key[] = $row['column_name'];
$primary_key_name = $row['index_name'];
}

				$primary_key[] = $row['column_name'];
$primary_key_name = $row['index_name'];
}

 

if($row['unique_key'] == 't')
{
$unique_keys[$row['index_name']][] = $row['column_name'];
}
}

if(!empty($primary_key))
{
$lines[] = " CONSTRAINT $primary_key_name PRIMARY KEY (".implode(', ', $primary_key).")";

		}


		}


		if(!empty($primary_key))

		foreach($unique_keys as $key_name => $key_columns)

		{

		{

			$lines[] = "  CONSTRAINT $primary_key_name PRIMARY KEY (".implode(', ', $primary_key).")";

			$lines[] = "  CONSTRAINT $key_name UNIQUE (".implode(', ', $key_columns).")";

		}

$table_lines .= implode(", \n", $lines);

		}

$table_lines .= implode(", \n", $lines);

Zeile 1171Zeile 1181

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


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

	 *

	 *

	 * @param string $table The table to be checked.
* @return boolean True or false if supported or not.
*/
function supports_fulltext_boolean($table)

	 * @param string $table The table to be checked.
* @return boolean True or false if supported or not.
*/
function supports_fulltext_boolean($table)

	{

	{

		return false;
}


		return false;
}


Zeile 1191Zeile 1201
	function create_fulltext_index($table, $column, $name="")
{
return false;

	function create_fulltext_index($table, $column, $name="")
{
return false;

	}

	}


/**
* Drop an index with the specified name from the specified table


/**
* Drop an index with the specified name from the specified table

Zeile 1213Zeile 1223
	 * @param string $table The name of the table.
* @param string $index The name of the index.
* @return bool Returns whether index exists

	 * @param string $table The name of the table.
* @param string $index The name of the index.
* @return bool Returns whether index exists

	 */

	 */

	function index_exists($table, $index)
{
$err = $this->error_reporting;
$this->error_reporting = 0;

	function index_exists($table, $index)
{
$err = $this->error_reporting;
$this->error_reporting = 0;





		$query = $this->write_query("SELECT * FROM pg_indexes WHERE tablename='".$this->escape_string($this->table_prefix.$table)."'");

$exists = $this->fetch_field($query, $index);
$this->error_reporting = $err;

		$query = $this->write_query("SELECT * FROM pg_indexes WHERE tablename='".$this->escape_string($this->table_prefix.$table)."'");

$exists = $this->fetch_field($query, $index);
$this->error_reporting = $err;





		if($exists)
{
return true;

		if($exists)
{
return true;

		}
else

		}
else

		{
return false;
}
}

		{
return false;
}
}





	/**
* Drop an table with the specified table
*

	/**
* Drop an table with the specified table
*

Zeile 1244Zeile 1254
	function drop_table($table, $hard=false, $table_prefix=true)
{
if($table_prefix == false)

	function drop_table($table, $hard=false, $table_prefix=true)
{
if($table_prefix == false)

		{

		{

			$table_prefix = "";
}
else

			$table_prefix = "";
}
else

Zeile 1255Zeile 1265
		if($hard == false)
{
if($this->table_exists($table))

		if($hard == false)
{
if($this->table_exists($table))

			{

			{

				$this->write_query('DROP TABLE '.$table_prefix.$table);
}

				$this->write_query('DROP TABLE '.$table_prefix.$table);
}

		}
else
{

		}
else
{

			$this->write_query('DROP TABLE '.$table_prefix.$table);
}

$query = $this->query("SELECT column_name FROM information_schema.constraint_column_usage WHERE table_name = '{$table}' and constraint_name = '{$table}_pkey' LIMIT 1");

			$this->write_query('DROP TABLE '.$table_prefix.$table);
}

$query = $this->query("SELECT column_name FROM information_schema.constraint_column_usage WHERE table_name = '{$table}' and constraint_name = '{$table}_pkey' LIMIT 1");

		$field = $this->fetch_field($query, 'column_name');

		$field = $this->fetch_field($query, 'column_name');


// Do we not have a primary field?
if($field)
{
$this->write_query('DROP SEQUENCE {$table}_{$field}_id_seq');


// Do we not have a primary field?
if($field)
{
$this->write_query('DROP SEQUENCE {$table}_{$field}_id_seq');

		}

		}

	}

/**
* Renames a table

	}

/**
* Renames a table

	 *

	 *

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

Zeile 1287Zeile 1297
		if($table_prefix == false)
{
$table_prefix = "";

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

		}

		}

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

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





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

/**
* Replace contents of table with values

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

/**
* Replace contents of table with values

	 *

	 *

	 * @param string $table The table
* @param array $replacements The replacements
* @param string|array $default_field The default field(s)

	 * @param string $table The table
* @param array $replacements The replacements
* @param string|array $default_field The default field(s)

Zeile 1313Zeile 1323
		{
$query = $this->write_query("SELECT column_name FROM information_schema.constraint_column_usage WHERE table_name = '{$this->table_prefix}{$table}' and constraint_name = '{$this->table_prefix}{$table}_pkey' LIMIT 1");
$main_field = $this->fetch_field($query, 'column_name');

		{
$query = $this->write_query("SELECT column_name FROM information_schema.constraint_column_usage WHERE table_name = '{$this->table_prefix}{$table}' and constraint_name = '{$this->table_prefix}{$table}_pkey' LIMIT 1");
$main_field = $this->fetch_field($query, 'column_name');

		}
else

		}
else

		{
$main_field = $default_field;
}

$update = false;
$search_bit = array();

		{
$main_field = $default_field;
}

$update = false;
$search_bit = array();

		if(is_array($main_field) && !empty($main_field))








if(!is_array($main_field))
{
$main_field = array($main_field);
}

foreach($main_field as $field)

		{

		{

			foreach($main_field as $field)

			if(isset($mybb->binary_fields[$table][$field]) && $mybb->binary_fields[$table][$field])

			{

			{

				if(isset($mybb->binary_fields[$table][$field]) && $mybb->binary_fields[$table][$field])
{
$search_bit[] = "{$field} = ".$replacements[$field];
}
else
{
$search_bit[] = "{$field} = ".$this->quote_val($replacements[$field]);
}
}

$search_bit = implode(" AND ", $search_bit);
$query = $this->write_query("SELECT COUNT(".$main_field[0].") as count FROM {$this->table_prefix}{$table} WHERE {$search_bit} LIMIT 1");
if($this->fetch_field($query, "count") == 1)
{
$update = true;
}
}
else
{
$query = $this->write_query("SELECT {$main_field} FROM {$this->table_prefix}{$table}");

while($column = $this->fetch_array($query))
{
if($column[$main_field] == $replacements[$main_field])
{
$update = true;
break;
}

				$search_bit[] = "{$field} = ".$replacements[$field];




























			}

			}

 
			else
{
$search_bit[] = "{$field} = ".$this->quote_val($replacements[$field]);
}
}
$search_bit = implode(" AND ", $search_bit);
$query = $this->write_query("SELECT COUNT(".$main_field[0].") as count FROM {$this->table_prefix}{$table} WHERE {$search_bit} LIMIT 1");
if($this->fetch_field($query, "count") == 1)
{
$update = true;

		}

if($update === true)

		}

if($update === true)

		{
if(is_array($main_field))
{
return $this->update_query($table, $replacements, $search_bit);
}
else
{
return $this->update_query($table, $replacements, "{$main_field}=".$this->quote_val($replacements[$main_field]));
}
}
else
{

		{
return $this->update_query($table, $replacements, $search_bit);
}
else
{








			return $this->insert_query($table, $replacements, $insert_id);
}
}

			return $this->insert_query($table, $replacements, $insert_id);
}
}

Zeile 1424Zeile 1416
	 * @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

	 * @param boolean $new_not_null Whether to drop or set a column
* @param boolean $new_default_value The new default value (if one is to be set)

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

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

Zeile 1449Zeile 1441
			$result2 = $this->write_query("ALTER TABLE {$this->table_prefix}{$table} ALTER COLUMN {$column} {$set_drop} NOT NULL");
}


			$result2 = $this->write_query("ALTER TABLE {$this->table_prefix}{$table} ALTER COLUMN {$column} {$set_drop} NOT NULL");
}


		if($new_default_value !== false)

		if($new_default_value !== null)

		{

		{

			$result3 = $this->write_query("ALTER TABLE {$this->table_prefix}{$table} ALTER COLUMN {$column} SET DEFAULT {$new_default_value}");
}
else
{
$result3 = $this->write_query("ALTER TABLE {$this->table_prefix}{$table} ALTER COLUMN {$column} DROP DEFAULT");




			if($new_default_value !== false)
{
$result3 = $this->write_query("ALTER TABLE {$this->table_prefix}{$table} ALTER COLUMN {$column} SET DEFAULT {$new_default_value}");
}
else
{
$result3 = $this->write_query("ALTER TABLE {$this->table_prefix}{$table} ALTER COLUMN {$column} DROP DEFAULT");
}

		}

return $result1 && $result2 && $result3;

		}

return $result1 && $result2 && $result3;

Zeile 1468Zeile 1463
	 * @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

	 * @param boolean $new_not_null Whether to drop or set a column
* @param boolean $new_default_value The new default value (if one is to be set)

	 * @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, $new_not_null=false, $new_default_value=false)

	 * @return bool Returns true if all queries are executed successfully
*/
function rename_column($table, $old_column, $new_column, $new_definition, $new_not_null=false, $new_default_value=false)