Vergleich inc/db_pgsql.php - 1.6.2 - 1.6.16

  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 5028 2010-06-16 05:50:39Z RyanGordon $

 * $Id$

 */

class DB_PgSQL

 */

class DB_PgSQL

Zeile 143Zeile 143
	 * @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
*/
public $last_result;


/**
* Connect to the database server.


/**
* Connect to the database server.

Zeile 199Zeile 206
			foreach($connections[$type] as $single_connection)
{
$connect_function = "pg_connect";

			foreach($connections[$type] as $single_connection)
{
$connect_function = "pg_connect";

				if($single_connection['pconnect'])

				if(isset($single_connection['pconnect']))

				{
$connect_function = "pg_pconnect";
}

				{
$connect_function = "pg_pconnect";
}

Zeile 282Zeile 289
	{
global $pagestarttime, $db, $mybb;


	{
global $pagestarttime, $db, $mybb;


		$string = preg_replace("#LIMIT ([0-9]+),([ 0-9]+)#i", "LIMIT $2 OFFSET $1", $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 321Zeile 328
		$query_time = $this->get_execution_time();
$this->query_time += $query_time;
$this->query_count++;

		$query_time = $this->get_execution_time();
$this->query_time += $query_time;
$this->query_count++;

 
		$this->last_result = $query;

		
if($mybb->debug_mode)
{

		
if($mybb->debug_mode)
{

Zeile 357Zeile 365
				"<td colspan=\"8\" style=\"background-color: #ccc;\"><strong>#".$this->query_count." - Select Query</strong></td>\n".
"</tr>\n".
"<tr>\n".

				"<td colspan=\"8\" style=\"background-color: #ccc;\"><strong>#".$this->query_count." - Select Query</strong></td>\n".
"</tr>\n".
"<tr>\n".

				"<td colspan=\"8\" style=\"background-color: #fefefe;\"><span style=\"font-family: Courier; font-size: 14px;\">".$string."</span></td>\n".

				"<td colspan=\"8\" style=\"background-color: #fefefe;\"><span style=\"font-family: Courier; font-size: 14px;\">".htmlspecialchars_uni($string)."</span></td>\n".

				"</tr>\n".
"<tr style=\"background-color: #efefef;\">\n".
"<td><strong>Info</strong></td>\n".

				"</tr>\n".
"<tr style=\"background-color: #efefef;\">\n".
"<td><strong>Info</strong></td>\n".

Zeile 405Zeile 413
	 * @param constant The type of array to return.
* @return array The array of results.
*/

	 * @param constant The type of array to return.
* @return array The array of results.
*/

	function fetch_array($query)

	function fetch_array($query, $resulttype=PGSQL_ASSOC)

	{

	{

		$array = pg_fetch_assoc($query);
return $array;
}









		switch($resulttype)
{
case PGSQL_NUM:
case PGSQL_BOTH:
break;
default:
$resulttype = PGSQL_ASSOC;
break;
}

$array = pg_fetch_array($query, NULL, $resulttype);





	/**




		return $array;
}

/**

	 * Return a specific field from a query.
*
* @param resource The query ID.

	 * Return a specific field from a query.
*
* @param resource The query ID.

Zeile 436Zeile 455
	 *
* @param resource The query ID.
* @param int The pointer to move the row to.

	 *
* @param resource The query ID.
* @param int The pointer to move the row to.

	 */

	 */

	function data_seek($query, $row)
{
return pg_result_seek($query, $row);

	function data_seek($query, $row)
{
return pg_result_seek($query, $row);

Zeile 569Zeile 588
	 */
function affected_rows()
{

	 */
function affected_rows()
{

		return pg_affected_rows($this->current_link);

		return pg_affected_rows($this->last_result);

	}

/**

	}

/**

Zeile 721Zeile 740
	 * @return int The insert ID if available
*/
function insert_query($table, $array, $insert_id=true)

	 * @return int The insert ID if available
*/
function insert_query($table, $array, $insert_id=true)

	{
if(!is_array($array))
{

	{
if(!is_array($array))
{

			return false;
}


			return false;
}


Zeile 1295Zeile 1314
	 * @param string The table
* @param string The column name
* @param string the new column definition

	 * @param string The table
* @param string The column name
* @param string the new column definition

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

	 */

	 */

	function modify_column($table, $column, $new_definition)

	function modify_column($table, $column, $new_definition, $new_not_null=false, $new_default_value=false)

	{

	{

		return $this->write_query("ALTER TABLE {$this->table_prefix}{$table} ALTER COLUMN {$column} TYPE {$new_definition}");





























		$result1 = $result2 = $result3 = true;

if($new_definition !== false)
{
$result1 = $this->write_query("ALTER TABLE {$this->table_prefix}{$table} ALTER COLUMN {$column} TYPE {$new_definition}");
}

if($new_not_null !== false)
{
$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");
}

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;

	}

/**

	}

/**

Zeile 1308Zeile 1357
	 * @param string The old column name
* @param string the new column name
* @param string the new column definition

	 * @param string The old column name
* @param string the new column name
* @param string the new column definition

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

	 */

	 */

	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)

	{
$result1 = $this->write_query("ALTER TABLE {$this->table_prefix}{$table} RENAME COLUMN {$old_column} TO {$new_column}");

	{
$result1 = $this->write_query("ALTER TABLE {$this->table_prefix}{$table} RENAME COLUMN {$old_column} TO {$new_column}");

		$result2 = $this->modify_column($table, $new_column, $new_definition);

		$result2 = $this->modify_column($table, $new_column, $new_definition, $new_not_null, $new_default_value);

		return ($result1 && $result2);
}


		return ($result1 && $result2);
}