Vergleich inc/db_pgsql.php - 1.8.8 - 1.8.21

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 1093Zeile 1093

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


// We do this in two steps. It makes placing the comma easier
while($row = $this->fetch_array($query))

Zeile 1101Zeile 1103
			{
$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))
{
$lines[] = " CONSTRAINT $primary_key_name PRIMARY KEY (".implode(', ', $primary_key).")";

 
		}

foreach($unique_keys as $key_name => $key_columns)
{
$lines[] = " CONSTRAINT $key_name UNIQUE (".implode(', ', $key_columns).")";

		}

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

		}

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

Zeile 1114Zeile 1126

return $table_lines;
}


return $table_lines;
}





	/**
* Show the "show fields from" command for a specific table.
*

	/**
* Show the "show fields from" command for a specific table.
*

Zeile 1135Zeile 1147
		while($field = $this->fetch_array($query))
{
if($field['field'] == $primary_key)

		while($field = $this->fetch_array($query))
{
if($field['field'] == $primary_key)

			{

			{

				$field['extra'] = 'auto_increment';
}


				$field['extra'] = 'auto_increment';
}


Zeile 1143Zeile 1155
		}

return $field_info;

		}

return $field_info;

	}

/**

	}

/**

	 * Returns whether or not the table contains a fulltext index.
*
* @param string $table The name of the table.

	 * Returns whether or not the table contains a fulltext index.
*
* @param string $table The name of the table.

Zeile 1153Zeile 1165
	 * @return boolean True or false if the table has a fulltext index or not.
*/
function is_fulltext($table, $index="")

	 * @return boolean True or false if the table has a fulltext index or not.
*/
function is_fulltext($table, $index="")

	{
return false;
}

	{
return false;
}


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


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

	 *
* @param string $table The table to be checked.

	 *
* @param string $table The table to be checked.

	 * @return boolean True or false if supported or not.
*/

function supports_fulltext($table)

	 * @return boolean True or false if supported or not.
*/

function supports_fulltext($table)

	{

	{

		return false;
}


		return false;
}


Zeile 1176Zeile 1188
	 * @return boolean True or false if supported or not.
*/
function supports_fulltext_boolean($table)

	 * @return boolean True or false if supported or not.
*/
function supports_fulltext_boolean($table)

	{
return false;

	{
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.

	 *
* @param string $table The name of the table.

	 *
* @param string $table The name of the table.

	 * @param string $column Name of the column to be indexed.
* @param string $name The index name, optional.
* @return bool

	 * @param string $column Name of the column to be indexed.
* @param string $name The index name, optional.
* @return bool

Zeile 1191Zeile 1203
	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
*
* @param string $table The name of the table.
* @param string $name The name of the index.

	 * Drop an index with the specified name from the specified table
*
* @param string $table The name of the table.
* @param string $name The name of the index.

	 */

	 */

	function drop_index($table, $name)
{
$this->write_query("

	function drop_index($table, $name)
{
$this->write_query("

Zeile 1218Zeile 1230
	{
$err = $this->error_reporting;
$this->error_reporting = 0;

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

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

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

Zeile 1227Zeile 1239
		if($exists)
{
return true;

		if($exists)
{
return true;

		}

		}

		else
{
return false;

		else
{
return false;

Zeile 1246Zeile 1258
		if($table_prefix == false)
{
$table_prefix = "";

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

		}
else

		}
else

		{
$table_prefix = $this->table_prefix;
}

		{
$table_prefix = $this->table_prefix;
}

Zeile 1257Zeile 1269
			if($this->table_exists($table))
{
$this->write_query('DROP TABLE '.$table_prefix.$table);

			if($this->table_exists($table))
{
$this->write_query('DROP TABLE '.$table_prefix.$table);

			}
}
else
{

			}
}
else
{

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


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


Zeile 1321Zeile 1333

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


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

		if(is_array($main_field) && !empty($main_field))
{
foreach($main_field as $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;
}
}
}

 




		if($update === true)

		if(!is_array($main_field))

		{

		{

			if(is_array($main_field))
{
return $this->update_query($table, $replacements, $search_bit);






			$main_field = array($main_field);
}

foreach($main_field as $field)
{
if(isset($mybb->binary_fields[$table][$field]) && $mybb->binary_fields[$table][$field])
{
$search_bit[] = "{$field} = ".$replacements[$field];

			}
else
{

			}
else
{

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

				$search_bit[] = "{$field} = ".$this->quote_val($replacements[$field]);

			}
}

			}
}

		else












		$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)
{
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 1389Zeile 1383
			$fieldstring .= $comma.$append.$field['Field'];
$comma = ',';
}

			$fieldstring .= $comma.$append.$field['Field'];
$comma = ',';
}





		return $fieldstring;
}


		return $fieldstring;
}


Zeile 1407Zeile 1401

/**
* Adds a column


/**
* Adds a column

	 *
* @param string $table The table
* @param string $column The column name

	 *
* @param string $table The table
* @param string $column The column name

	 * @param string $definition the new column definition
* @return resource
*/

	 * @param string $definition the new column definition
* @return resource
*/

Zeile 1424Zeile 1418
	 * @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 1442Zeile 1436
			$set_drop = "DROP";

if(strtolower($new_not_null) == "set")

			$set_drop = "DROP";

if(strtolower($new_not_null) == "set")

			{

			{

				$set_drop = "SET";
}

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


				$set_drop = "SET";
}

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