[Qual] Mysqli: set charset with recommended method
This commit is contained in:
parent
7fd2cbea49
commit
daa3ce3591
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2006-2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
/* Copyright (C) 2006-2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
||||||
|
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -417,8 +418,14 @@ function backup_tables($outputfile, $tables='*')
|
|||||||
global $errormsg;
|
global $errormsg;
|
||||||
|
|
||||||
// Set to UTF-8
|
// Set to UTF-8
|
||||||
|
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 NAMES utf8');
|
||||||
$db->query('SET CHARACTER SET utf8');
|
$db->query('SET CHARACTER SET utf8');
|
||||||
|
}
|
||||||
|
|
||||||
//get all of the tables
|
//get all of the tables
|
||||||
if ($tables == '*')
|
if ($tables == '*')
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||||
|
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -115,10 +116,8 @@ class DoliDBMysqli extends DoliDB
|
|||||||
$clientmustbe='';
|
$clientmustbe='';
|
||||||
if (preg_match('/UTF-8/i',$conf->file->character_set_client)) $clientmustbe='utf8';
|
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 (preg_match('/ISO-8859-1/i',$conf->file->character_set_client)) $clientmustbe='latin1';
|
||||||
if ($this->db->character_set_name() != $clientmustbe)
|
if ($this->db->character_set_name() != $clientmustbe) {
|
||||||
{
|
$this->db->set_charset($clientmustbe);
|
||||||
$this->query("SET NAMES '".$clientmustbe."'", $this->db);
|
|
||||||
//$this->query("SET CHARACTER SET ". $this->forcecharset);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -141,10 +140,8 @@ class DoliDBMysqli extends DoliDB
|
|||||||
$clientmustbe='';
|
$clientmustbe='';
|
||||||
if (preg_match('/UTF-8/i',$conf->file->character_set_client)) $clientmustbe='utf8';
|
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 (preg_match('/ISO-8859-1/i',$conf->file->character_set_client)) $clientmustbe='latin1';
|
||||||
if ($this->db->character_set_name() != $clientmustbe)
|
if ($this->db->character_set_name() != $clientmustbe) {
|
||||||
{
|
$this->db->set_charset($clientmustbe);
|
||||||
$this->query("SET NAMES '".$clientmustbe."'", $this->db);
|
|
||||||
//$this->query("SET CHARACTER SET ". $this->forcecharset);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user