diff --git a/htdocs/admin/tools/export.php b/htdocs/admin/tools/export.php index c9e4211842d..c89fafbe052 100644 --- a/htdocs/admin/tools/export.php +++ b/htdocs/admin/tools/export.php @@ -1,6 +1,7 @@ - * Copyright (C) 2011 Juanjo Menent +/* Copyright (C) 2006-2014 Laurent Destailleur + * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2015 Raphaël Doursenaud * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -417,8 +418,14 @@ function backup_tables($outputfile, $tables='*') global $errormsg; // Set to UTF-8 - $db->query('SET NAMES utf8'); - $db->query('SET CHARACTER SET utf8'); + if(is_a($db, 'DoliDBMysqli')) { + /** @var DoliDBMysqli $db */ + $db->db->set_charset('utf8'); + } else { + /** @var DoliDB $db */ + $db->query('SET NAMES utf8'); + $db->query('SET CHARACTER SET utf8'); + } //get all of the tables if ($tables == '*') diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 04f6372055f..05e84d6dd50 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2015 Raphaël Doursenaud * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -115,11 +116,9 @@ class DoliDBMysqli extends DoliDB $clientmustbe=''; if (preg_match('/UTF-8/i',$conf->file->character_set_client)) $clientmustbe='utf8'; if (preg_match('/ISO-8859-1/i',$conf->file->character_set_client)) $clientmustbe='latin1'; - if ($this->db->character_set_name() != $clientmustbe) - { - $this->query("SET NAMES '".$clientmustbe."'", $this->db); - //$this->query("SET CHARACTER SET ". $this->forcecharset); - } + if ($this->db->character_set_name() != $clientmustbe) { + $this->db->set_charset($clientmustbe); + } } else { @@ -141,11 +140,9 @@ class DoliDBMysqli extends DoliDB $clientmustbe=''; if (preg_match('/UTF-8/i',$conf->file->character_set_client)) $clientmustbe='utf8'; if (preg_match('/ISO-8859-1/i',$conf->file->character_set_client)) $clientmustbe='latin1'; - if ($this->db->character_set_name() != $clientmustbe) - { - $this->query("SET NAMES '".$clientmustbe."'", $this->db); - //$this->query("SET CHARACTER SET ". $this->forcecharset); - } + if ($this->db->character_set_name() != $clientmustbe) { + $this->db->set_charset($clientmustbe); + } } }