From c1611fd3f6b572f17eec04c113272a76667fdad7 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Tue, 4 Oct 2016 23:43:44 -0400 Subject: [PATCH] Fix Issue #2816 - Add backward compatible server_info support --- include/dba.php | 16 ++++++++++++++++ include/dbstructure.php | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/include/dba.php b/include/dba.php index 97f6c87956..9ccdcd1304 100644 --- a/include/dba.php +++ b/include/dba.php @@ -91,6 +91,22 @@ class dba { return $this->db; } + /** Returns the MySQL server version string + * + * This function discriminate between the deprecated mysql API and the current + * object-oriented mysqli API. Example of returned string: 5.5.46-0+deb8u1 + * + * @return string + */ + public function server_info() { + if ($this->mysqli) { + $return = $this->db->server_info; + } else { + $return = mysql_get_server_info($this->db); + } + return $return; + } + public function q($sql, $onlyquery = false) { global $a; diff --git a/include/dbstructure.php b/include/dbstructure.php index 9e0020fdbe..d3b148b2a8 100644 --- a/include/dbstructure.php +++ b/include/dbstructure.php @@ -166,7 +166,7 @@ function update_structure($verbose, $action, $tables=null, $definition=null) { @$db->q($sql_config); // MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements - if (version_compare($db->getdb()->server_info, '5.7.4') >= 0) { + if (version_compare($db->server_info(), '5.7.4') >= 0) { $ignore = ''; }else { $ignore = ' IGNORE';