diff options
Diffstat (limited to 'phpBB/includes/db')
| -rw-r--r-- | phpBB/includes/db/db_tools.php | 8 | ||||
| -rw-r--r-- | phpBB/includes/db/dbal.php | 77 | ||||
| -rw-r--r-- | phpBB/includes/db/firebird.php | 38 | ||||
| -rw-r--r-- | phpBB/includes/db/mssql.php | 40 | ||||
| -rw-r--r-- | phpBB/includes/db/mssql_odbc.php | 29 | ||||
| -rw-r--r-- | phpBB/includes/db/mssqlnative.php | 29 | ||||
| -rw-r--r-- | phpBB/includes/db/mysql.php | 31 | ||||
| -rw-r--r-- | phpBB/includes/db/mysqli.php | 31 | ||||
| -rw-r--r-- | phpBB/includes/db/oracle.php | 23 | ||||
| -rw-r--r-- | phpBB/includes/db/postgres.php | 39 | ||||
| -rw-r--r-- | phpBB/includes/db/sqlite.php | 23 | 
11 files changed, 226 insertions, 142 deletions
diff --git a/phpBB/includes/db/db_tools.php b/phpBB/includes/db/db_tools.php index c6dd23e6bd..6df3aac9ce 100644 --- a/phpBB/includes/db/db_tools.php +++ b/phpBB/includes/db/db_tools.php @@ -2,9 +2,8 @@  /**  *  * @package dbal -* @version $Id$  * @copyright (c) 2007 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2  *  */ @@ -21,7 +20,6 @@ if (!defined('IN_PHPBB'))  * Currently not supported is returning SQL for creating tables.  *  * @package dbal -* @note currently not used within phpBB3, but may be utilized later.  */  class phpbb_db_tools  { @@ -1504,7 +1502,7 @@ class phpbb_db_tools  			$column_type = $this->dbms_type_map[$this->sql_layer][$column_data[0]];  		} -		// Adjust default value if db-dependant specified +		// Adjust default value if db-dependent specified  		if (is_array($column_data[1]))  		{  			$column_data[1] = (isset($column_data[1][$this->sql_layer])) ? $column_data[1][$this->sql_layer] : $column_data[1]['default']; @@ -2457,5 +2455,3 @@ class phpbb_db_tools  		return $this->_sql_run_sql($statements);  	}  } - -?>
\ No newline at end of file diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php index 9cc337955b..ef1dd7d14d 100644 --- a/phpBB/includes/db/dbal.php +++ b/phpBB/includes/db/dbal.php @@ -2,9 +2,8 @@  /**  *  * @package dbal -* @version $Id$  * @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2  *  */ @@ -207,7 +206,7 @@ class dbal  			$query_id = $this->query_result;  		} -		if (isset($cache->sql_rowset[$query_id])) +		if ($cache->sql_exists($query_id))  		{  			return $cache->sql_rowseek($rownum, $query_id);  		} @@ -257,7 +256,7 @@ class dbal  				$this->sql_rowseek($rownum, $query_id);  			} -			if (!is_object($query_id) && isset($cache->sql_rowset[$query_id])) +			if (!is_object($query_id) && $cache->sql_exists($query_id))  			{  				return $cache->sql_fetchfield($query_id, $field);  			} @@ -285,6 +284,37 @@ class dbal  	}  	/** +	* Build a case expression +	* +	* Note: The two statements action_true and action_false must have the same data type (int, vchar, ...) in the database! +	* +	* @param	string	$condition		The condition which must be true, to use action_true rather then action_else +	* @param	string	$action_true	SQL expression that is used, if the condition is true +	* @param	string	$action_else	SQL expression that is used, if the condition is false, optional +	* @return	string			CASE expression including the condition and statements +	*/ +	public function sql_case($condition, $action_true, $action_false = false) +	{ +		$sql_case = 'CASE WHEN ' . $condition; +		$sql_case .= ' THEN ' . $action_true; +		$sql_case .= ($action_false !== false) ? ' ELSE ' . $action_false : ''; +		$sql_case .= ' END'; +		return $sql_case; +	} + +	/** +	* Build a concatenated expression +	* +	* @param	string	$expr1		Base SQL expression where we append the second one +	* @param	string	$expr2		SQL expression that is appended to the first expression +	* @return	string		Concatenated string +	*/ +	public function sql_concatenate($expr1, $expr2) +	{ +		return $expr1 . ' || ' . $expr2; +	} + +	/**  	* Returns whether results of a query need to be buffered to run a transaction while iterating over them.  	*  	* @return bool Whether buffering is required. @@ -501,6 +531,28 @@ class dbal  	}  	/** +	* Returns SQL string to cast a string expression to an int. +	* +	* @param  string $expression An expression evaluating to string +	* @return string             Expression returning an int +	*/ +	function cast_expr_to_bigint($expression) +	{ +		return $expression; +	} + +	/** +	* Returns SQL string to cast an integer expression to a string. +	* +	* @param  string $expression An expression evaluating to int +	* @return string             Expression returning a string +	*/ +	function cast_expr_to_string($expression) +	{ +		return $expression; +	} + +	/**  	* Run LOWER() on DB column of type text (i.e. neither varchar nor char).  	*  	* @param string $column_name	The column name to use @@ -714,8 +766,8 @@ class dbal  			// Show complete SQL error and path to administrators only  			// Additionally show complete error on installation or if extended debug mode is enabled -			// The DEBUG_EXTRA constant is for development only! -			if ((isset($auth) && $auth->acl_get('a_')) || defined('IN_INSTALL') || defined('DEBUG_EXTRA')) +			// The DEBUG constant is for development only! +			if ((isset($auth) && $auth->acl_get('a_')) || defined('IN_INSTALL') || defined('DEBUG'))  			{  				$message .= ($sql) ? '<br /><br />SQL<br /><br />' . htmlspecialchars($sql) : '';  			} @@ -771,8 +823,9 @@ class dbal  	function sql_report($mode, $query = '')  	{  		global $cache, $starttime, $phpbb_root_path, $user; +		global $request; -		if (empty($_REQUEST['explain'])) +		if (is_object($request) && !$request->variable('explain', false))  		{  			return false;  		} @@ -794,12 +847,10 @@ class dbal  				$mtime = explode(' ', microtime());  				$totaltime = $mtime[0] + $mtime[1] - $starttime; -				echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -					<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr"> +				echo '<!DOCTYPE html> +					<html dir="ltr">  					<head> -						<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> -						<meta http-equiv="Content-Style-Type" content="text/css" /> -						<meta http-equiv="imagetoolbar" content="no" /> +						<meta charset="utf-8">  						<title>SQL Report</title>  						<link href="' . $phpbb_root_path . 'adm/style/admin.css" rel="stylesheet" type="text/css" media="screen" />  					</head> @@ -996,5 +1047,3 @@ class dbal  * This variable holds the class name to use later  */  $sql_db = (!empty($dbms)) ? 'dbal_' . basename($dbms) : 'dbal'; - -?>
\ No newline at end of file diff --git a/phpBB/includes/db/firebird.php b/phpBB/includes/db/firebird.php index 7072c58ac0..5728eb901c 100644 --- a/phpBB/includes/db/firebird.php +++ b/phpBB/includes/db/firebird.php @@ -2,9 +2,8 @@  /**  *  * @package dbal -* @version $Id$  * @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2  *  */ @@ -151,13 +150,13 @@ class dbal_firebird extends dbal  			global $cache;  			// EXPLAIN only in extra debug mode -			if (defined('DEBUG_EXTRA')) +			if (defined('DEBUG'))  			{  				$this->sql_report('start', $query);  			}  			$this->last_query_text = $query; -			$this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false; +			$this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false;  			$this->sql_add_num_queries($this->query_result);  			if ($this->query_result === false) @@ -252,7 +251,7 @@ class dbal_firebird extends dbal  					$this->sql_error($query);  				} -				if (defined('DEBUG_EXTRA')) +				if (defined('DEBUG'))  				{  					$this->sql_report('stop', $query);  				} @@ -270,17 +269,17 @@ class dbal_firebird extends dbal  					}  				} -				if ($cache_ttl && method_exists($cache, 'sql_save')) +				if ($cache_ttl)  				{  					$this->open_queries[(int) $this->query_result] = $this->query_result; -					$cache->sql_save($query, $this->query_result, $cache_ttl); +					$this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl);  				}  				else if (strpos($query, 'SELECT') === 0 && $this->query_result)  				{  					$this->open_queries[(int) $this->query_result] = $this->query_result;  				}  			} -			else if (defined('DEBUG_EXTRA')) +			else if (defined('DEBUG'))  			{  				$this->sql_report('fromcache', $query);  			} @@ -333,7 +332,7 @@ class dbal_firebird extends dbal  			$query_id = $this->query_result;  		} -		if (isset($cache->sql_rowset[$query_id])) +		if ($cache->sql_exists($query_id))  		{  			return $cache->sql_fetchrow($query_id);  		} @@ -399,7 +398,7 @@ class dbal_firebird extends dbal  			$query_id = $this->query_result;  		} -		if (isset($cache->sql_rowset[$query_id])) +		if ($cache->sql_exists($query_id))  		{  			return $cache->sql_freeresult($query_id);  		} @@ -450,6 +449,23 @@ class dbal_firebird extends dbal  	}  	/** +	* @inheritdoc +	*/ +	function cast_expr_to_bigint($expression) +	{ +		// Precision must be from 1 to 18 +		return 'CAST(' . $expression . ' as DECIMAL(18, 0))'; +	} + +	/** +	* @inheritdoc +	*/ +	function cast_expr_to_string($expression) +	{ +		return 'CAST(' . $expression . ' as VARCHAR(255))'; +	} + +	/**  	* return sql error array  	* @access private  	*/ @@ -522,5 +538,3 @@ class dbal_firebird extends dbal  		}  	}  } - -?>
\ No newline at end of file diff --git a/phpBB/includes/db/mssql.php b/phpBB/includes/db/mssql.php index b7178593dc..1ec8517308 100644 --- a/phpBB/includes/db/mssql.php +++ b/phpBB/includes/db/mssql.php @@ -2,9 +2,8 @@  /**  *  * @package dbal -* @version $Id$  * @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2  *  */ @@ -41,14 +40,7 @@ class dbal_mssql extends dbal  		@ini_set('mssql.textlimit', 2147483647);  		@ini_set('mssql.textsize', 2147483647); -		if (version_compare(PHP_VERSION, '5.1.0', '>=') || (version_compare(PHP_VERSION, '5.0.0-dev', '<=') && version_compare(PHP_VERSION, '4.4.1', '>='))) -		{ -			$this->db_connect_id = ($this->persistency) ? @mssql_pconnect($this->server, $this->user, $sqlpassword, $new_link) : @mssql_connect($this->server, $this->user, $sqlpassword, $new_link); -		} -		else -		{ -			$this->db_connect_id = ($this->persistency) ? @mssql_pconnect($this->server, $this->user, $sqlpassword) : @mssql_connect($this->server, $this->user, $sqlpassword); -		} +		$this->db_connect_id = ($this->persistency) ? @mssql_pconnect($this->server, $this->user, $sqlpassword, $new_link) : @mssql_connect($this->server, $this->user, $sqlpassword, $new_link);  		if ($this->db_connect_id && $this->dbname != '')  		{ @@ -100,6 +92,14 @@ class dbal_mssql extends dbal  	}  	/** +	* {@inheritDoc} +	*/ +	public function sql_concatenate($expr1, $expr2) +	{ +		return $expr1 . ' + ' . $expr2; +	} + +	/**  	* SQL Transaction  	* @access private  	*/ @@ -139,12 +139,12 @@ class dbal_mssql extends dbal  			global $cache;  			// EXPLAIN only in extra debug mode -			if (defined('DEBUG_EXTRA')) +			if (defined('DEBUG'))  			{  				$this->sql_report('start', $query);  			} -			$this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false; +			$this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false;  			$this->sql_add_num_queries($this->query_result);  			if ($this->query_result === false) @@ -154,22 +154,22 @@ class dbal_mssql extends dbal  					$this->sql_error($query);  				} -				if (defined('DEBUG_EXTRA')) +				if (defined('DEBUG'))  				{  					$this->sql_report('stop', $query);  				} -				if ($cache_ttl && method_exists($cache, 'sql_save')) +				if ($cache_ttl)  				{  					$this->open_queries[(int) $this->query_result] = $this->query_result; -					$cache->sql_save($query, $this->query_result, $cache_ttl); +					$this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl);  				}  				else if (strpos($query, 'SELECT') === 0 && $this->query_result)  				{  					$this->open_queries[(int) $this->query_result] = $this->query_result;  				}  			} -			else if (defined('DEBUG_EXTRA')) +			else if (defined('DEBUG'))  			{  				$this->sql_report('fromcache', $query);  			} @@ -234,7 +234,7 @@ class dbal_mssql extends dbal  			$query_id = $this->query_result;  		} -		if (isset($cache->sql_rowset[$query_id])) +		if ($cache->sql_exists($query_id))  		{  			return $cache->sql_fetchrow($query_id);  		} @@ -271,7 +271,7 @@ class dbal_mssql extends dbal  			$query_id = $this->query_result;  		} -		if (isset($cache->sql_rowset[$query_id])) +		if ($cache->sql_exists($query_id))  		{  			return $cache->sql_rowseek($rownum, $query_id);  		} @@ -310,7 +310,7 @@ class dbal_mssql extends dbal  			$query_id = $this->query_result;  		} -		if (isset($cache->sql_rowset[$query_id])) +		if ($cache->sql_exists($query_id))  		{  			return $cache->sql_freeresult($query_id);  		} @@ -454,5 +454,3 @@ class dbal_mssql extends dbal  		}  	}  } - -?>
\ No newline at end of file diff --git a/phpBB/includes/db/mssql_odbc.php b/phpBB/includes/db/mssql_odbc.php index 2ecc42cadf..7c1ffbc808 100644 --- a/phpBB/includes/db/mssql_odbc.php +++ b/phpBB/includes/db/mssql_odbc.php @@ -2,9 +2,8 @@  /**  *  * @package dbal -* @version $Id$  * @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2  *  */ @@ -111,6 +110,14 @@ class dbal_mssql_odbc extends dbal  	}  	/** +	* {@inheritDoc} +	*/ +	public function sql_concatenate($expr1, $expr2) +	{ +		return $expr1 . ' + ' . $expr2; +	} + +	/**  	* SQL Transaction  	* @access private  	*/ @@ -150,13 +157,13 @@ class dbal_mssql_odbc extends dbal  			global $cache;  			// EXPLAIN only in extra debug mode -			if (defined('DEBUG_EXTRA')) +			if (defined('DEBUG'))  			{  				$this->sql_report('start', $query);  			}  			$this->last_query_text = $query; -			$this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false; +			$this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false;  			$this->sql_add_num_queries($this->query_result);  			if ($this->query_result === false) @@ -166,22 +173,22 @@ class dbal_mssql_odbc extends dbal  					$this->sql_error($query);  				} -				if (defined('DEBUG_EXTRA')) +				if (defined('DEBUG'))  				{  					$this->sql_report('stop', $query);  				} -				if ($cache_ttl && method_exists($cache, 'sql_save')) +				if ($cache_ttl)  				{  					$this->open_queries[(int) $this->query_result] = $this->query_result; -					$cache->sql_save($query, $this->query_result, $cache_ttl); +					$this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl);  				}  				else if (strpos($query, 'SELECT') === 0 && $this->query_result)  				{  					$this->open_queries[(int) $this->query_result] = $this->query_result;  				}  			} -			else if (defined('DEBUG_EXTRA')) +			else if (defined('DEBUG'))  			{  				$this->sql_report('fromcache', $query);  			} @@ -247,7 +254,7 @@ class dbal_mssql_odbc extends dbal  			$query_id = $this->query_result;  		} -		if (isset($cache->sql_rowset[$query_id])) +		if ($cache->sql_exists($query_id))  		{  			return $cache->sql_fetchrow($query_id);  		} @@ -288,7 +295,7 @@ class dbal_mssql_odbc extends dbal  			$query_id = $this->query_result;  		} -		if (isset($cache->sql_rowset[$query_id])) +		if ($cache->sql_exists($query_id))  		{  			return $cache->sql_freeresult($query_id);  		} @@ -388,5 +395,3 @@ class dbal_mssql_odbc extends dbal  		}  	}  } - -?>
\ No newline at end of file diff --git a/phpBB/includes/db/mssqlnative.php b/phpBB/includes/db/mssqlnative.php index 3ad0ff3e11..e9191fae8a 100644 --- a/phpBB/includes/db/mssqlnative.php +++ b/phpBB/includes/db/mssqlnative.php @@ -2,9 +2,8 @@  /**  *  * @package dbal -* @version $Id$  * @copyright (c) 2010 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2  *  * This is the MS SQL Server Native database abstraction layer.  * PHP mssql native driver required. @@ -260,6 +259,14 @@ class dbal_mssqlnative extends dbal  	/**  	* {@inheritDoc}  	*/ +	public function sql_concatenate($expr1, $expr2) +	{ +		return $expr1 . ' + ' . $expr2; +	} + +	/** +	* {@inheritDoc} +	*/  	function sql_buffer_nested_transactions()  	{  		return true; @@ -304,13 +311,13 @@ class dbal_mssqlnative extends dbal  			global $cache;  			// EXPLAIN only in extra debug mode -			if (defined('DEBUG_EXTRA')) +			if (defined('DEBUG'))  			{  				$this->sql_report('start', $query);  			}  			$this->last_query_text = $query; -			$this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false; +			$this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false;  			$this->sql_add_num_queries($this->query_result);  			if ($this->query_result === false) @@ -322,22 +329,22 @@ class dbal_mssqlnative extends dbal  				// reset options for next query  				$this->query_options = array(); -				if (defined('DEBUG_EXTRA')) +				if (defined('DEBUG'))  				{  					$this->sql_report('stop', $query);  				} -				if ($cache_ttl && method_exists($cache, 'sql_save')) +				if ($cache_ttl)  				{  					$this->open_queries[(int) $this->query_result] = $this->query_result; -					$cache->sql_save($query, $this->query_result, $cache_ttl); +					$this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl);  				}  				else if (strpos($query, 'SELECT') === 0 && $this->query_result)  				{  					$this->open_queries[(int) $this->query_result] = $this->query_result;  				}  			} -			else if (defined('DEBUG_EXTRA')) +			else if (defined('DEBUG'))  			{  				$this->sql_report('fromcache', $query);  			} @@ -410,7 +417,7 @@ class dbal_mssqlnative extends dbal  			$query_id = $this->query_result;  		} -		if (isset($cache->sql_rowset[$query_id])) +		if ($cache->sql_exists($query_id))  		{  			return $cache->sql_fetchrow($query_id);  		} @@ -470,7 +477,7 @@ class dbal_mssqlnative extends dbal  			$query_id = $this->query_result;  		} -		if (isset($cache->sql_rowset[$query_id])) +		if ($cache->sql_exists($query_id))  		{  			return $cache->sql_freeresult($query_id);  		} @@ -634,5 +641,3 @@ class dbal_mssqlnative extends dbal  		$this->query_options = $options;  	}  } - -?> diff --git a/phpBB/includes/db/mysql.php b/phpBB/includes/db/mysql.php index 1ccb785150..f685ab055c 100644 --- a/phpBB/includes/db/mysql.php +++ b/phpBB/includes/db/mysql.php @@ -2,9 +2,8 @@  /**  *  * @package dbal -* @version $Id$  * @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2  *  */ @@ -121,6 +120,14 @@ class dbal_mysql extends dbal  	}  	/** +	* {@inheritDoc} +	*/ +	public function sql_concatenate($expr1, $expr2) +	{ +		return 'CONCAT(' . $expr1 . ', ' . $expr2 . ')'; +	} + +	/**  	* SQL Transaction  	* @access private  	*/ @@ -160,12 +167,12 @@ class dbal_mysql extends dbal  			global $cache;  			// EXPLAIN only in extra debug mode -			if (defined('DEBUG_EXTRA')) +			if (defined('DEBUG'))  			{  				$this->sql_report('start', $query);  			} -			$this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false; +			$this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false;  			$this->sql_add_num_queries($this->query_result);  			if ($this->query_result === false) @@ -175,22 +182,22 @@ class dbal_mysql extends dbal  					$this->sql_error($query);  				} -				if (defined('DEBUG_EXTRA')) +				if (defined('DEBUG'))  				{  					$this->sql_report('stop', $query);  				} -				if ($cache_ttl && method_exists($cache, 'sql_save')) +				if ($cache_ttl)  				{  					$this->open_queries[(int) $this->query_result] = $this->query_result; -					$cache->sql_save($query, $this->query_result, $cache_ttl); +					$this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl);  				}  				else if (strpos($query, 'SELECT') === 0 && $this->query_result)  				{  					$this->open_queries[(int) $this->query_result] = $this->query_result;  				}  			} -			else if (defined('DEBUG_EXTRA')) +			else if (defined('DEBUG'))  			{  				$this->sql_report('fromcache', $query);  			} @@ -242,7 +249,7 @@ class dbal_mysql extends dbal  			$query_id = $this->query_result;  		} -		if (isset($cache->sql_rowset[$query_id])) +		if ($cache->sql_exists($query_id))  		{  			return $cache->sql_fetchrow($query_id);  		} @@ -263,7 +270,7 @@ class dbal_mysql extends dbal  			$query_id = $this->query_result;  		} -		if (isset($cache->sql_rowset[$query_id])) +		if ($cache->sql_exists($query_id))  		{  			return $cache->sql_rowseek($rownum, $query_id);  		} @@ -291,7 +298,7 @@ class dbal_mysql extends dbal  			$query_id = $this->query_result;  		} -		if (isset($cache->sql_rowset[$query_id])) +		if ($cache->sql_exists($query_id))  		{  			return $cache->sql_freeresult($query_id);  		} @@ -558,5 +565,3 @@ class dbal_mysql extends dbal  		}  	}  } - -?>
\ No newline at end of file diff --git a/phpBB/includes/db/mysqli.php b/phpBB/includes/db/mysqli.php index a311b8cda6..6d81b8bc3e 100644 --- a/phpBB/includes/db/mysqli.php +++ b/phpBB/includes/db/mysqli.php @@ -2,9 +2,8 @@  /**  *  * @package dbal -* @version $Id$  * @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2  *  */ @@ -124,6 +123,14 @@ class dbal_mysqli extends dbal  	}  	/** +	* {@inheritDoc} +	*/ +	public function sql_concatenate($expr1, $expr2) +	{ +		return 'CONCAT(' . $expr1 . ', ' . $expr2 . ')'; +	} + +	/**  	* SQL Transaction  	* @access private  	*/ @@ -167,12 +174,12 @@ class dbal_mysqli extends dbal  			global $cache;  			// EXPLAIN only in extra debug mode -			if (defined('DEBUG_EXTRA')) +			if (defined('DEBUG'))  			{  				$this->sql_report('start', $query);  			} -			$this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false; +			$this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false;  			$this->sql_add_num_queries($this->query_result);  			if ($this->query_result === false) @@ -182,17 +189,17 @@ class dbal_mysqli extends dbal  					$this->sql_error($query);  				} -				if (defined('DEBUG_EXTRA')) +				if (defined('DEBUG'))  				{  					$this->sql_report('stop', $query);  				} -				if ($cache_ttl && method_exists($cache, 'sql_save')) +				if ($cache_ttl)  				{ -					$cache->sql_save($query, $this->query_result, $cache_ttl); +					$this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl);  				}  			} -			else if (defined('DEBUG_EXTRA')) +			else if (defined('DEBUG'))  			{  				$this->sql_report('fromcache', $query);  			} @@ -244,7 +251,7 @@ class dbal_mysqli extends dbal  			$query_id = $this->query_result;  		} -		if (!is_object($query_id) && isset($cache->sql_rowset[$query_id])) +		if (!is_object($query_id) && $cache->sql_exists($query_id))  		{  			return $cache->sql_fetchrow($query_id);  		} @@ -271,7 +278,7 @@ class dbal_mysqli extends dbal  			$query_id = $this->query_result;  		} -		if (!is_object($query_id) && isset($cache->sql_rowset[$query_id])) +		if (!is_object($query_id) && $cache->sql_exists($query_id))  		{  			return $cache->sql_rowseek($rownum, $query_id);  		} @@ -299,7 +306,7 @@ class dbal_mysqli extends dbal  			$query_id = $this->query_result;  		} -		if (!is_object($query_id) && isset($cache->sql_rowset[$query_id])) +		if (!is_object($query_id) && $cache->sql_exists($query_id))  		{  			return $cache->sql_freeresult($query_id);  		} @@ -559,5 +566,3 @@ class dbal_mysqli extends dbal  		}  	}  } - -?>
\ No newline at end of file diff --git a/phpBB/includes/db/oracle.php b/phpBB/includes/db/oracle.php index 62b36aa8bf..6d9339b2d8 100644 --- a/phpBB/includes/db/oracle.php +++ b/phpBB/includes/db/oracle.php @@ -2,9 +2,8 @@  /**  *  * @package dbal -* @version $Id$  * @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2  *  */ @@ -237,13 +236,13 @@ class dbal_oracle extends dbal  			global $cache;  			// EXPLAIN only in extra debug mode -			if (defined('DEBUG_EXTRA')) +			if (defined('DEBUG'))  			{  				$this->sql_report('start', $query);  			}  			$this->last_query_text = $query; -			$this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false; +			$this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false;  			$this->sql_add_num_queries($this->query_result);  			if ($this->query_result === false) @@ -414,22 +413,22 @@ class dbal_oracle extends dbal  					}  				} -				if (defined('DEBUG_EXTRA')) +				if (defined('DEBUG'))  				{  					$this->sql_report('stop', $query);  				} -				if ($cache_ttl && method_exists($cache, 'sql_save')) +				if ($cache_ttl)  				{  					$this->open_queries[(int) $this->query_result] = $this->query_result; -					$cache->sql_save($query, $this->query_result, $cache_ttl); +					$this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl);  				}  				else if (strpos($query, 'SELECT') === 0 && $this->query_result)  				{  					$this->open_queries[(int) $this->query_result] = $this->query_result;  				}  			} -			else if (defined('DEBUG_EXTRA')) +			else if (defined('DEBUG'))  			{  				$this->sql_report('fromcache', $query);  			} @@ -474,7 +473,7 @@ class dbal_oracle extends dbal  			$query_id = $this->query_result;  		} -		if (isset($cache->sql_rowset[$query_id])) +		if ($cache->sql_exists($query_id))  		{  			return $cache->sql_fetchrow($query_id);  		} @@ -526,7 +525,7 @@ class dbal_oracle extends dbal  			$query_id = $this->query_result;  		} -		if (isset($cache->sql_rowset[$query_id])) +		if ($cache->sql_exists($query_id))  		{  			return $cache->sql_rowseek($rownum, $query_id);  		} @@ -595,7 +594,7 @@ class dbal_oracle extends dbal  			$query_id = $this->query_result;  		} -		if (isset($cache->sql_rowset[$query_id])) +		if ($cache->sql_exists($query_id))  		{  			return $cache->sql_freeresult($query_id);  		} @@ -767,5 +766,3 @@ class dbal_oracle extends dbal  		}  	}  } - -?>
\ No newline at end of file diff --git a/phpBB/includes/db/postgres.php b/phpBB/includes/db/postgres.php index bb116e0763..8dfbfc3b60 100644 --- a/phpBB/includes/db/postgres.php +++ b/phpBB/includes/db/postgres.php @@ -2,9 +2,8 @@  /**  *  * @package dbal -* @version $Id$  * @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2  *  */ @@ -195,13 +194,13 @@ class dbal_postgres extends dbal  			global $cache;  			// EXPLAIN only in extra debug mode -			if (defined('DEBUG_EXTRA')) +			if (defined('DEBUG'))  			{  				$this->sql_report('start', $query);  			}  			$this->last_query_text = $query; -			$this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false; +			$this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false;  			$this->sql_add_num_queries($this->query_result);  			if ($this->query_result === false) @@ -211,22 +210,22 @@ class dbal_postgres extends dbal  					$this->sql_error($query);  				} -				if (defined('DEBUG_EXTRA')) +				if (defined('DEBUG'))  				{  					$this->sql_report('stop', $query);  				} -				if ($cache_ttl && method_exists($cache, 'sql_save')) +				if ($cache_ttl)  				{  					$this->open_queries[(int) $this->query_result] = $this->query_result; -					$cache->sql_save($query, $this->query_result, $cache_ttl); +					$this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl);  				}  				else if (strpos($query, 'SELECT') === 0 && $this->query_result)  				{  					$this->open_queries[(int) $this->query_result] = $this->query_result;  				}  			} -			else if (defined('DEBUG_EXTRA')) +			else if (defined('DEBUG'))  			{  				$this->sql_report('fromcache', $query);  			} @@ -286,7 +285,7 @@ class dbal_postgres extends dbal  			$query_id = $this->query_result;  		} -		if (isset($cache->sql_rowset[$query_id])) +		if ($cache->sql_exists($query_id))  		{  			return $cache->sql_fetchrow($query_id);  		} @@ -307,7 +306,7 @@ class dbal_postgres extends dbal  			$query_id = $this->query_result;  		} -		if (isset($cache->sql_rowset[$query_id])) +		if ($cache->sql_exists($query_id))  		{  			return $cache->sql_rowseek($rownum, $query_id);  		} @@ -356,7 +355,7 @@ class dbal_postgres extends dbal  			$query_id = $this->query_result;  		} -		if (isset($cache->sql_rowset[$query_id])) +		if ($cache->sql_exists($query_id))  		{  			return $cache->sql_freeresult($query_id);  		} @@ -389,6 +388,22 @@ class dbal_postgres extends dbal  	}  	/** +	* @inheritdoc +	*/ +	function cast_expr_to_bigint($expression) +	{ +		return 'CAST(' . $expression . ' as DECIMAL(255, 0))'; +	} + +	/** +	* @inheritdoc +	*/ +	function cast_expr_to_string($expression) +	{ +		return 'CAST(' . $expression . ' as VARCHAR(255))'; +	} + +	/**  	* return sql error array  	* @access private  	*/ @@ -481,5 +496,3 @@ class dbal_postgres extends dbal  		}  	}  } - -?>
\ No newline at end of file diff --git a/phpBB/includes/db/sqlite.php b/phpBB/includes/db/sqlite.php index 8de72fd394..5fc89ced18 100644 --- a/phpBB/includes/db/sqlite.php +++ b/phpBB/includes/db/sqlite.php @@ -2,9 +2,8 @@  /**  *  * @package dbal -* @version $Id$  * @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2  *  */ @@ -113,12 +112,12 @@ class dbal_sqlite extends dbal  			global $cache;  			// EXPLAIN only in extra debug mode -			if (defined('DEBUG_EXTRA')) +			if (defined('DEBUG'))  			{  				$this->sql_report('start', $query);  			} -			$this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false; +			$this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false;  			$this->sql_add_num_queries($this->query_result);  			if ($this->query_result === false) @@ -128,22 +127,22 @@ class dbal_sqlite extends dbal  					$this->sql_error($query);  				} -				if (defined('DEBUG_EXTRA')) +				if (defined('DEBUG'))  				{  					$this->sql_report('stop', $query);  				} -				if ($cache_ttl && method_exists($cache, 'sql_save')) +				if ($cache_ttl)  				{  					$this->open_queries[(int) $this->query_result] = $this->query_result; -					$cache->sql_save($query, $this->query_result, $cache_ttl); +					$this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl);  				}  				else if (strpos($query, 'SELECT') === 0 && $this->query_result)  				{  					$this->open_queries[(int) $this->query_result] = $this->query_result;  				}  			} -			else if (defined('DEBUG_EXTRA')) +			else if (defined('DEBUG'))  			{  				$this->sql_report('fromcache', $query);  			} @@ -194,7 +193,7 @@ class dbal_sqlite extends dbal  			$query_id = $this->query_result;  		} -		if (isset($cache->sql_rowset[$query_id])) +		if ($cache->sql_exists($query_id))  		{  			return $cache->sql_fetchrow($query_id);  		} @@ -215,7 +214,7 @@ class dbal_sqlite extends dbal  			$query_id = $this->query_result;  		} -		if (isset($cache->sql_rowset[$query_id])) +		if ($cache->sql_exists($query_id))  		{  			return $cache->sql_rowseek($rownum, $query_id);  		} @@ -243,7 +242,7 @@ class dbal_sqlite extends dbal  			$query_id = $this->query_result;  		} -		if (isset($cache->sql_rowset[$query_id])) +		if ($cache->sql_exists($query_id))  		{  			return $cache->sql_freeresult($query_id);  		} @@ -335,5 +334,3 @@ class dbal_sqlite extends dbal  		}  	}  } - -?>
\ No newline at end of file  | 
