Vergleich inc/db_pgsql.php - 1.4.2 - 1.4.4

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 6Zeile 6
 * Website: http://www.mybboard.com
* License: http://www.mybboard.com/license.php
*

 * Website: http://www.mybboard.com
* License: http://www.mybboard.com/license.php
*

 * $Id: db_pgsql.php 4067 2008-08-04 03:59:08Z Tikitiki $

 * $Id: db_pgsql.php 4274 2008-11-19 03:22:50Z Tikitiki $

 */

class DB_PgSQL

 */

class DB_PgSQL

Zeile 157Zeile 157
		{
$connections['read'][] = $config;
}

		{
$connections['read'][] = $config;
}

 
		else

		// Connecting to more than one server
{
// Specified multiple servers, but no specific read/write servers

		// Connecting to more than one server
{
// Specified multiple servers, but no specific read/write servers

Zeile 288Zeile 289
		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);

 
			if(strstr($string, 'CHANGE') !== false)
{
$string = str_replace(' CHANGE ', ' ALTER ', $string);
}

		}

if($write_query && $this->write_link)

		}

if($write_query && $this->write_link)

Zeile 444Zeile 449
	function num_rows($query)
{
return pg_num_rows($query);

	function num_rows($query)
{
return pg_num_rows($query);

	}

	}


/**
* Return the last id number of inserted data.


/**
* Return the last id number of inserted data.

Zeile 452Zeile 457
	 * @return int The id number.
*/
function insert_id()

	 * @return int The id number.
*/
function insert_id()

	{

	{

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


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


Zeile 469Zeile 474
		
$id = $this->query("SELECT currval('{$table}_{$field}_seq') AS last_value");
return $this->fetch_field($id, 'last_value');

		
$id = $this->query("SELECT currval('{$table}_{$field}_seq') AS last_value");
return $this->fetch_field($id, 'last_value');

	}


	}


	/**
* Close the connection with the DBMS.
*

	/**
* Close the connection with the DBMS.
*

Zeile 514Zeile 519
		if($this->current_link)
{
return pg_last_error($this->current_link);

		if($this->current_link)
{
return pg_last_error($this->current_link);

		}
else
{

		}
else
{

			return pg_last_error();
}
}

			return pg_last_error();
}
}

Zeile 525Zeile 530
	 * Output a database error.
*
* @param string The string to present as an error.

	 * Output a database error.
*
* @param string The string to present as an error.

	 */

	 */

	function error($string="", $query="")
{
if($this->error_reporting)

	function error($string="", $query="")
{
if($this->error_reporting)

Zeile 552Zeile 557
				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);
}
}

	}


	}



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


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

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

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

	{

	{

		return pg_affected_rows($this->current_link);
}


		return pg_affected_rows($this->current_link);
}


Zeile 570Zeile 575
	 *
* @param resource The query ID.
* @return int The number of fields.

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

	 */

	 */

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

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

Zeile 588Zeile 593
		if($prefix)
{
$query = $this->query("SELECT table_name FROM information_schema.tables WHERE table_schema='public' AND table_name LIKE '".$this->escape_string($prefix)."%'");

		if($prefix)
{
$query = $this->query("SELECT table_name FROM information_schema.tables WHERE table_schema='public' AND table_name LIKE '".$this->escape_string($prefix)."%'");

		}

		}

		else
{
$query = $this->query("SELECT table_name FROM information_schema.tables WHERE table_schema='public'");

		else
{
$query = $this->query("SELECT table_name FROM information_schema.tables WHERE table_schema='public'");

Zeile 718Zeile 723
	 *
* @param string The table name to perform the query on.
* @param array An array of fields and their values.

	 *
* @param string The table name to perform the query on.
* @param array An array of fields and their values.

 
	 * @param boolean Whether or not to return an insert id. True by default

	 * @return int The insert ID if available
*/

	 * @return int The insert ID if available
*/

	function insert_query($table, $array)

	function insert_query($table, $array, $insert_id=true)

	{
if(!is_array($array))
{

	{
if(!is_array($array))
{

Zeile 733Zeile 739
			INTO {$this->table_prefix}{$table} (".$fields.") 
VALUES ('".$values."')
");

			INTO {$this->table_prefix}{$table} (".$fields.") 
VALUES ('".$values."')
");

		return $this->insert_id();









		
if($insert_id != false)
{
return $this->insert_id();
}
else
{
return true;
}

	}

/**

	}

/**

Zeile 957Zeile 971
	 */
function optimize_table($table)
{

	 */
function optimize_table($table)
{

		$this->write_query("OPTIMIZE TABLE ".$this->table_prefix.$table."");

		$this->write_query("VACUUM ".$this->table_prefix.$table."");

	}

/**

	}

/**

Zeile 967Zeile 981
	 */
function analyze_table($table)
{

	 */
function analyze_table($table)
{

		$this->write_query("ANALYZE TABLE ".$this->table_prefix.$table."");

		$this->write_query("ANALYZE ".$this->table_prefix.$table."");

	}

/**

	}

/**

Zeile 1204Zeile 1218
	 *
* @param string The table
* @param array The replacements

	 *
* @param string The table
* @param array The replacements

 
	 * @param string The default field
* @param boolean Whether or not to return an insert id. True by default

	 */

	 */

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

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

	{
$i = 0;


	{
$i = 0;


Zeile 1235Zeile 1251
		}
else
{

		}
else
{

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

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

		}
}


		}
}


Zeile 1244Zeile 1260
	 *
* @param string The table
* @param array The replacements

	 *
* @param string The table
* @param array The replacements

 
	 * @param string The default field

	 */
function build_replace_query($table, $replacements=array(), $default_field="")
{

	 */
function build_replace_query($table, $replacements=array(), $default_field="")
{