Vergleich inc/db_pgsql.php - 1.8.27 - 1.8.37

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 23Zeile 23
	 * @var string
*/
public $short_title = "PostgreSQL";

	 * @var string
*/
public $short_title = "PostgreSQL";

 

/**
* The type of db software being used.
*
* @var string
*/
public $type;


/**
* A count of the number of queries.


/**
* A count of the number of queries.

Zeile 44Zeile 51
	 * @var boolean
*/
public $error_reporting = 1;

	 * @var boolean
*/
public $error_reporting = 1;





	/**
* The read database connection resource.
*

	/**
* The read database connection resource.
*

Zeile 65Zeile 72
	 * @var resource
*/
public $current_link;

	 * @var resource
*/
public $current_link;

 

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


/**
* Explanation of a query.


/**
* Explanation of a query.

	 *
* @var string

	 *
* @var string

	 */
public $explain;

	 */
public $explain;


/**


/**

	 * The current version of PgSQL.
*
* @var string

	 * The current version of PgSQL.
*
* @var string

Zeile 82Zeile 94

/**
* The current table type in use (myisam/innodb)


/**
* The current table type in use (myisam/innodb)

	 *
* @var string
*/

	 *
* @var string
*/

	public $table_type = "myisam";

	public $table_type = "myisam";


/**


/**

	 * The table prefix used for simple select, update, insert and delete queries

	 * The table prefix used for simple select, update, insert and delete queries

	 *

	 *

	 * @var string
*/
public $table_prefix;

	 * @var string
*/
public $table_prefix;


/**


/**

	 * The temperary connection string used to store connect details
*
* @var string

	 * The temperary connection string used to store connect details
*
* @var string

Zeile 103Zeile 115

/**
* The last query run on the database


/**
* The last query run on the database

	 *

	 *

	 * @var string
*/
public $last_query;

	 * @var string
*/
public $last_query;

Zeile 142Zeile 154
	 * @var float
*/
public $query_time = 0;

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


/**


/**

	 * The last result run on the database (needed for affected_rows)
*
* @var resource

	 * The last result run on the database (needed for affected_rows)
*
* @var resource

Zeile 182Zeile 194
		}

if(isset($config['encoding']))

		}

if(isset($config['encoding']))

		{

		{

			$this->db_encoding = $config['encoding'];
}


			$this->db_encoding = $config['encoding'];
}


Zeile 222Zeile 234
				if(strpos($single_connection['hostname'], ':') !== false)
{
list($single_connection['hostname'], $single_connection['port']) = explode(':', $single_connection['hostname']);

				if(strpos($single_connection['hostname'], ':') !== false)
{
list($single_connection['hostname'], $single_connection['port']) = explode(':', $single_connection['hostname']);

				}

				}

				else
{
$single_connection['port'] = null;

				else
{
$single_connection['port'] = null;

				}


				}


				if($single_connection['port'])
{
$this->connect_string .= " port={$single_connection['port']}";

				if($single_connection['port'])
{
$this->connect_string .= " port={$single_connection['port']}";

				}


				}


				if($single_connection['hostname'] != "")

				if($single_connection['hostname'] != "")

				{

				{

					$this->connect_string .= " host={$single_connection['hostname']}";
}

if($single_connection['password'])
{
$this->connect_string .= " password={$single_connection['password']}";

					$this->connect_string .= " host={$single_connection['hostname']}";
}

if($single_connection['password'])
{
$this->connect_string .= " password={$single_connection['password']}";

				}

				}

				$this->$link = @$connect_function($this->connect_string);

$time_spent = get_execution_time();

				$this->$link = @$connect_function($this->connect_string);

$time_spent = get_execution_time();

Zeile 300Zeile 312
		$this->last_query = $string;

get_execution_time();

		$this->last_query = $string;

get_execution_time();





		if(strtolower(substr(ltrim($string), 0, 5)) == 'alter')
{
$string = preg_replace("#\sAFTER\s([a-z_]+?)(;*?)$#i", "", $string);

		if(strtolower(substr(ltrim($string), 0, 5)) == 'alter')
{
$string = preg_replace("#\sAFTER\s([a-z_]+?)(;*?)$#i", "", $string);

Zeile 339Zeile 351
		if($mybb->debug_mode)
{
$this->explain_query($string, $query_time);

		if($mybb->debug_mode)
{
$this->explain_query($string, $query_time);

		}

		}

		return $query;
}


		return $query;
}


Zeile 649Zeile 661
	{
// Execute on master server to ensure if we've just created a table that we get the correct result
$query = $this->write_query("SELECT COUNT(table_name) as table_names FROM information_schema.tables WHERE table_schema = 'public' AND table_name='{$this->table_prefix}{$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 COUNT(table_name) as table_names FROM information_schema.tables WHERE table_schema = 'public' AND table_name='{$this->table_prefix}{$table}'");


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

if($exists > 0)
{


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

if($exists > 0)
{

			return true;
}
else

			return true;
}
else

Zeile 943Zeile 955
	{
if(function_exists("pg_escape_string"))
{

	{
if(function_exists("pg_escape_string"))
{

			$string = pg_escape_string($string);

			$string = pg_escape_string($this->read_link, $string);

		}
else
{

		}
else
{

Zeile 968Zeile 980
	 *
* @param string $string The string to be escaped.
* @return string The escaped string.

	 *
* @param string $string The string to be escaped.
* @return string The escaped string.

	 */

	 */

	function escape_string_like($string)
{
return $this->escape_string(str_replace(array('\\', '%', '_') , array('\\\\', '\\%' , '\\_') , $string));

	function escape_string_like($string)
{
return $this->escape_string(str_replace(array('\\', '%', '_') , array('\\\\', '\\%' , '\\_') , $string));

Zeile 1146Zeile 1158
		$primary_key = $this->fetch_field($query, 'column_name');

$query = $this->write_query("

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

$query = $this->write_query("

			SELECT column_name as Field, data_type as Extra

			SELECT column_name, data_type, is_nullable, column_default, character_maximum_length, numeric_precision, numeric_precision_radix, numeric_scale

			FROM information_schema.columns
WHERE table_name = '{$this->table_prefix}{$table}'
");
$field_info = array();
while($field = $this->fetch_array($query))
{

			FROM information_schema.columns
WHERE table_name = '{$this->table_prefix}{$table}'
");
$field_info = array();
while($field = $this->fetch_array($query))
{

			if($field['field'] == $primary_key)

			if($field['column_name'] == $primary_key)

			{

			{

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

























				$field['_key'] = 'PRI';
}
else
{
$field['_key'] = '';
}

if(stripos($field['column_default'], 'nextval') !== false)
{
$field['_extra'] = 'auto_increment';
}
else
{
$field['_extra'] = '';
}

// bit, character, text fields.
if(!is_null($field['character_maximum_length']))
{
$field['data_type'] .= '('.(int)$field['character_maximum_length'].')';
}
// numeric/decimal fields.
else if($field['numeric_precision_radix'] == 10 && !is_null($field['numeric_precision']) && !is_null($field['numeric_scale']))
{
$field['data_type'] .= '('.(int)$field['numeric_precision'].','.(int)$field['numeric_scale'].')';

			}


			}


			$field_info[] = array('Extra' => $field['extra'], 'Field' => $field['field']);








			$field_info[] = array(
'Field' => $field['column_name'],
'Type' => $field['data_type'],
'Null' => $field['is_nullable'],
'Key' => $field['_key'],
'Default' => $field['column_default'],
'Extra' => $field['_extra'],
);

		}

		}





		return $field_info;
}


		return $field_info;
}


Zeile 1172Zeile 1215
	 * @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.
*
* @param string $table The table to be checked.
* @return boolean True or false if supported or not.
*/

	 * Returns whether or not this database engine supports fulltext indexing.
*
* @param string $table The table to be checked.
* @return boolean True or false if supported or not.
*/





	function supports_fulltext($table)
{
return false;

	function supports_fulltext($table)
{
return false;

Zeile 1190Zeile 1233

/**
* 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.
*/

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

Zeile 1206Zeile 1249
	 * @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

	 */

	 */

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

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

Zeile 1269Zeile 1312
		else
{
$table_prefix = $this->table_prefix;

		else
{
$table_prefix = $this->table_prefix;

		}






		}

$table_prefix_bak = $this->table_prefix;
$this->table_prefix = '';
$fields = array_column($this->show_fields_from($table_prefix.$table), 'Field');


		if($hard == false)

		if($hard == false)

		{
if($this->table_exists($table))

		{
if($this->table_exists($table_prefix.$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);
}


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

// Do we not have a primary field?
if($field)

		$this->table_prefix = $table_prefix_bak;

if(!empty($fields))



		{

		{

			$this->write_query('DROP SEQUENCE {$table}_{$field}_id_seq');




















			foreach($fields as &$field)
{
$field = "{$table_prefix}{$table}_{$field}_seq";
}
unset($field);

if(version_compare($this->get_version(), '8.2.0', '>='))
{
$fields = implode(', ', $fields);
$this->write_query("DROP SEQUENCE IF EXISTS {$fields}");
}
else
{
$fields = "'".implode("', '", $fields)."'";
$query = $this->query("SELECT sequence_name as field FROM information_schema.sequences WHERE sequence_name in ({$fields}) AND sequence_schema = 'public'");
while($row = $this->fetch_array($query))
{
$this->write_query("DROP SEQUENCE {$row['field']}");
}
}

		}
}


		}
}


Zeile 1566Zeile 1630
	 */
function escape_binary($string)
{

	 */
function escape_binary($string)
{

		return "'".pg_escape_bytea($string)."'";

		return "'".pg_escape_bytea($this->read_link, $string)."'";

	}

/**

	}

/**