Fix Issue #2816 - Add backward compatible server_info support

This commit is contained in:
Hypolite Petovan 2016-10-04 23:43:44 -04:00
parent a052fe4a98
commit c1611fd3f6
2 changed files with 17 additions and 1 deletions

View file

@ -91,6 +91,22 @@ class dba {
return $this->db; 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) { public function q($sql, $onlyquery = false) {
global $a; global $a;

View file

@ -166,7 +166,7 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
@$db->q($sql_config); @$db->q($sql_config);
// MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements // 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 = ''; $ignore = '';
}else { }else {
$ignore = ' IGNORE'; $ignore = ' IGNORE';