diff options
| author | Meik Sievertsen <acydburn@phpbb.com> | 2008-09-04 12:01:47 +0000 | 
|---|---|---|
| committer | Meik Sievertsen <acydburn@phpbb.com> | 2008-09-04 12:01:47 +0000 | 
| commit | 2fcd96ca72741bdfb36c24a0af9dd8230b5a828f (patch) | |
| tree | af6068957c73f64d5885311396c1d7730aa30b3c /phpBB/includes/db/mysqli.php | |
| parent | 4a225280a0fe1b7c364a007eb43dc93975c544e9 (diff) | |
| download | forums-2fcd96ca72741bdfb36c24a0af9dd8230b5a828f.tar forums-2fcd96ca72741bdfb36c24a0af9dd8230b5a828f.tar.gz forums-2fcd96ca72741bdfb36c24a0af9dd8230b5a828f.tar.bz2 forums-2fcd96ca72741bdfb36c24a0af9dd8230b5a828f.tar.xz forums-2fcd96ca72741bdfb36c24a0af9dd8230b5a828f.zip | |
Ok, story real database server info, as well as caching it
Store it on installation too - allows us to check the db version used on installation and used currently to warn the user about incompatibilities
git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8814 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/db/mysqli.php')
| -rw-r--r-- | phpBB/includes/db/mysqli.php | 26 | 
1 files changed, 23 insertions, 3 deletions
| diff --git a/phpBB/includes/db/mysqli.php b/phpBB/includes/db/mysqli.php index e8fd35f859..f0e58fd148 100644 --- a/phpBB/includes/db/mysqli.php +++ b/phpBB/includes/db/mysqli.php @@ -45,12 +45,14 @@ class dbal_mysqli extends dbal  		if ($this->db_connect_id && $this->dbname != '')  		{  			@mysqli_query($this->db_connect_id, "SET NAMES 'utf8'"); +  			// enforce strict mode on databases that support it -			if (mysqli_get_server_version($this->db_connect_id) >= 50002) +			if (version_compare($this->sql_server_info(true), '5.0.2', '>='))  			{  				$result = @mysqli_query($this->db_connect_id, 'SELECT @@session.sql_mode AS sql_mode');  				$row = @mysqli_fetch_assoc($result);  				@mysqli_free_result($result); +  				$modes = array_map('trim', explode(',', $row['sql_mode']));  				// TRADITIONAL includes STRICT_ALL_TABLES and STRICT_TRANS_TABLES @@ -78,10 +80,28 @@ class dbal_mysqli extends dbal  	/**  	* Version information about used database +	* @param bool $raw if true, only return the fetched sql_server_version +	* @return string sql server version  	*/ -	function sql_server_info() +	function sql_server_info($raw = false)  	{ -		return 'MySQL(i) ' . @mysqli_get_server_info($this->db_connect_id); +		global $cache; + +		if (empty($cache) || ($this->sql_server_version = $cache->get('mysqli_version')) === false) +		{ +			$result = @mysqli_query($this->db_connect_id, 'SELECT VERSION() AS version'); +			$row = @mysqli_fetch_assoc($result); +			@mysqli_free_result($result); + +			$this->sql_server_version = $row['version']; + +			if (!empty($cache)) +			{ +				$cache->put('mysqli_version', $this->sql_server_version); +			} +		} + +		return ($raw) ? $this->sql_server_version : 'MySQL(i) ' . $this->sql_server_version;  	}  	/** | 
