diff options
Diffstat (limited to 'phpBB/phpbb/db/driver/mssql_odbc.php')
| -rw-r--r-- | phpBB/phpbb/db/driver/mssql_odbc.php | 76 | 
1 files changed, 42 insertions, 34 deletions
| diff --git a/phpBB/phpbb/db/driver/mssql_odbc.php b/phpBB/phpbb/db/driver/mssql_odbc.php index f8c70f1cd7..9d9ad603e0 100644 --- a/phpBB/phpbb/db/driver/mssql_odbc.php +++ b/phpBB/phpbb/db/driver/mssql_odbc.php @@ -1,9 +1,13 @@  <?php  /**  * -* @package dbal -* @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file.  *  */ @@ -17,8 +21,6 @@ namespace phpbb\db\driver;  * @note number of bytes returned for returning data depends on odbc.defaultlrl php.ini setting.  * If it is limited to 4K for example only 4K of data is returned max, resulting in incomplete theme data for example.  * @note odbc.defaultbinmode may affect UTF8 characters -* -* @package dbal  */  class mssql_odbc extends \phpbb\db\driver\mssql_base  { @@ -26,7 +28,7 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base  	var $connect_error = '';  	/** -	* Connect to server +	* {@inheritDoc}  	*/  	function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false)  	{ @@ -83,10 +85,7 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base  	}  	/** -	* Version information about used database -	* @param bool $raw if true, only return the fetched sql_server_version -	* @param bool $use_cache If true, it is safe to retrieve the value from the cache -	* @return string sql server version +	* {@inheritDoc}  	*/  	function sql_server_info($raw = false, $use_cache = true)  	{ @@ -99,8 +98,8 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base  			$row = false;  			if ($result_id)  			{ -				$row = @odbc_fetch_array($result_id); -				@odbc_free_result($result_id); +				$row = odbc_fetch_array($result_id); +				odbc_free_result($result_id);  			}  			$this->sql_server_version = ($row) ? trim(implode(' ', $row)) : 0; @@ -144,13 +143,7 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base  	}  	/** -	* Base query method -	* -	* @param	string	$query		Contains the SQL query which shall be executed -	* @param	int		$cache_ttl	Either 0 to avoid caching or the time in seconds which the result shall be kept in cache -	* @return	mixed				When casted to bool the returned value returns true on success and false on failure -	* -	* @access	public +	* {@inheritDoc}  	*/  	function sql_query($query = '', $cache_ttl = 0)  	{ @@ -163,6 +156,10 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base  			{  				$this->sql_report('start', $query);  			} +			else if (defined('PHPBB_DISPLAY_LOAD_TIME')) +			{ +				$this->curtime = microtime(true); +			}  			$this->last_query_text = $query;  			$this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false; @@ -179,13 +176,22 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base  				{  					$this->sql_report('stop', $query);  				} +				else if (defined('PHPBB_DISPLAY_LOAD_TIME')) +				{ +					$this->sql_time += microtime(true) - $this->curtime; +				} + +				if (!$this->query_result) +				{ +					return false; +				}  				if ($cache && $cache_ttl)  				{  					$this->open_queries[(int) $this->query_result] = $this->query_result;  					$this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl);  				} -				else if (strpos($query, 'SELECT') === 0 && $this->query_result) +				else if (strpos($query, 'SELECT') === 0)  				{  					$this->open_queries[(int) $this->query_result] = $this->query_result;  				} @@ -236,7 +242,7 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base  	}  	/** -	* Return number of affected rows +	* {@inheritDoc}  	*/  	function sql_affectedrows()  	{ @@ -244,8 +250,7 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base  	}  	/** -	* Fetch current row -	* @note number of bytes returned depends on odbc.defaultlrl php.ini setting. If it is limited to 4K for example only 4K of data is returned max. +	* {@inheritDoc}  	*/  	function sql_fetchrow($query_id = false)  	{ @@ -261,11 +266,11 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base  			return $cache->sql_fetchrow($query_id);  		} -		return ($query_id !== false) ? @odbc_fetch_array($query_id) : false; +		return ($query_id) ? odbc_fetch_array($query_id) : false;  	}  	/** -	* Get last inserted id after insert statement +	* {@inheritDoc}  	*/  	function sql_nextid()  	{ @@ -273,20 +278,20 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base  		if ($result_id)  		{ -			if (@odbc_fetch_array($result_id)) +			if (odbc_fetch_array($result_id))  			{ -				$id = @odbc_result($result_id, 1); -				@odbc_free_result($result_id); +				$id = odbc_result($result_id, 1); +				odbc_free_result($result_id);  				return $id;  			} -			@odbc_free_result($result_id); +			odbc_free_result($result_id);  		}  		return false;  	}  	/** -	* Free sql result +	* {@inheritDoc}  	*/  	function sql_freeresult($query_id = false)  	{ @@ -305,7 +310,7 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base  		if (isset($this->open_queries[(int) $query_id]))  		{  			unset($this->open_queries[(int) $query_id]); -			return @odbc_free_result($query_id); +			return odbc_free_result($query_id);  		}  		return false; @@ -360,11 +365,14 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base  				$endtime = $endtime[0] + $endtime[1];  				$result = @odbc_exec($this->db_connect_id, $query); -				while ($void = @odbc_fetch_array($result)) +				if ($result)  				{ -					// Take the time spent on parsing rows into account +					while ($void = odbc_fetch_array($result)) +					{ +						// Take the time spent on parsing rows into account +					} +					odbc_free_result($result);  				} -				@odbc_free_result($result);  				$splittime = explode(' ', microtime());  				$splittime = $splittime[0] + $splittime[1]; | 
