Set MySQL Attribute for UTF8
This commit is contained in:
@@ -209,28 +209,27 @@ else {
|
|||||||
if (strlen($db_host) == 0 && strlen($db_port) == 0) {
|
if (strlen($db_host) == 0 && strlen($db_port) == 0) {
|
||||||
//if both host and port are empty use the unix socket
|
//if both host and port are empty use the unix socket
|
||||||
if (strlen($db_create_username) == 0) {
|
if (strlen($db_create_username) == 0) {
|
||||||
$db_dest = new PDO("mysql:host=$db_host;unix_socket=/var/run/mysqld/mysqld.sock;", $db_username, $db_password);
|
$db_dest = new PDO("mysql:host=$db_host;unix_socket=/var/run/mysqld/mysqld.sock;", $db_username, $db_password, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$db_dest = new PDO("mysql:host=$db_host;unix_socket=/var/run/mysqld/mysqld.sock;", $db_create_username, $db_create_password);
|
$db_dest = new PDO("mysql:host=$db_host;unix_socket=/var/run/mysqld/mysqld.sock;", $db_create_username, $db_create_password, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8')); }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (strlen($db_port) == 0) {
|
if (strlen($db_port) == 0) {
|
||||||
//leave out port if it is empty
|
//leave out port if it is empty
|
||||||
if (strlen($db_create_username) == 0) {
|
if (strlen($db_create_username) == 0) {
|
||||||
$db_dest = new PDO("mysql:host=$db_host;", $db_username, $db_password);
|
$db_dest = new PDO("mysql:host=$db_host;", $db_username, $db_password, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$db_dest = new PDO("mysql:host=$db_host;", $db_create_username, $db_create_password);
|
$db_dest = new PDO("mysql:host=$db_host;", $db_create_username, $db_create_password, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (strlen($db_create_username) == 0) {
|
if (strlen($db_create_username) == 0) {
|
||||||
$db_dest = new PDO("mysql:host=$db_host;port=$db_port;", $db_username, $db_password);
|
$db_dest = new PDO("mysql:host=$db_host;port=$db_port;", $db_username, $db_password, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$db_dest = new PDO("mysql:host=$db_host;port=$db_port;", $db_create_username, $db_create_password);
|
$db_dest = new PDO("mysql:host=$db_host;port=$db_port;", $db_create_username, $db_create_password, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -629,28 +629,27 @@ if ($_POST["install_step"] == "3" && count($_POST) > 0 && strlen($_POST["persist
|
|||||||
if (strlen($db_host) == 0 && strlen($db_port) == 0) {
|
if (strlen($db_host) == 0 && strlen($db_port) == 0) {
|
||||||
//if both host and port are empty use the unix socket
|
//if both host and port are empty use the unix socket
|
||||||
if (strlen($db_create_username) == 0) {
|
if (strlen($db_create_username) == 0) {
|
||||||
$db_tmp = new PDO("mysql:host=$db_host;unix_socket=/var/run/mysqld/mysqld.sock;", $db_username, $db_password);
|
$db_tmp = new PDO("mysql:host=$db_host;unix_socket=/var/run/mysqld/mysqld.sock;", $db_username, $db_password, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$db_tmp = new PDO("mysql:host=$db_host;unix_socket=/var/run/mysqld/mysqld.sock;", $db_create_username, $db_create_password);
|
$db_tmp = new PDO("mysql:host=$db_host;unix_socket=/var/run/mysqld/mysqld.sock;", $db_create_username, $db_create_password, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (strlen($db_port) == 0) {
|
if (strlen($db_port) == 0) {
|
||||||
//leave out port if it is empty
|
//leave out port if it is empty
|
||||||
if (strlen($db_create_username) == 0) {
|
if (strlen($db_create_username) == 0) {
|
||||||
$db_tmp = new PDO("mysql:host=$db_host;", $db_username, $db_password);
|
$db_tmp = new PDO("mysql:host=$db_host;", $db_username, $db_password, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$db_tmp = new PDO("mysql:host=$db_host;", $db_create_username, $db_create_password);
|
$db_tmp = new PDO("mysql:host=$db_host;", $db_create_username, $db_create_password, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8')); }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (strlen($db_create_username) == 0) {
|
if (strlen($db_create_username) == 0) {
|
||||||
$db_tmp = new PDO("mysql:host=$db_host;port=$db_port;", $db_username, $db_password);
|
$db_tmp = new PDO("mysql:host=$db_host;port=$db_port;", $db_username, $db_password, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$db_tmp = new PDO("mysql:host=$db_host;port=$db_port;", $db_create_username, $db_create_password);
|
$db_tmp = new PDO("mysql:host=$db_host;port=$db_port;", $db_create_username, $db_create_password, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -188,18 +188,20 @@ if ($db_type == "mysql") {
|
|||||||
//mysql pdo connection
|
//mysql pdo connection
|
||||||
if (strlen($db_host) == 0 && strlen($db_port) == 0) {
|
if (strlen($db_host) == 0 && strlen($db_port) == 0) {
|
||||||
//if both host and port are empty use the unix socket
|
//if both host and port are empty use the unix socket
|
||||||
$db = new PDO("mysql:host=$db_host;unix_socket=/var/run/mysqld/mysqld.sock;dbname=$db_name", $db_username, $db_password);
|
$db = new PDO("mysql:host=$db_host;unix_socket=/var/run/mysqld/mysqld.sock;dbname=$db_name", $db_username, $db_password, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (strlen($db_port) == 0) {
|
if (strlen($db_port) == 0) {
|
||||||
//leave out port if it is empty
|
//leave out port if it is empty
|
||||||
$db = new PDO("mysql:host=$db_host;dbname=$db_name;", $db_username, $db_password, array(
|
$db = new PDO("mysql:host=$db_host;dbname=$db_name;", $db_username, $db_password, array(
|
||||||
|
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
|
||||||
PDO::ATTR_ERRMODE,
|
PDO::ATTR_ERRMODE,
|
||||||
PDO::ERRMODE_EXCEPTION
|
PDO::ERRMODE_EXCEPTION
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$db = new PDO("mysql:host=$db_host;port=$db_port;dbname=$db_name;", $db_username, $db_password, array(
|
$db = new PDO("mysql:host=$db_host;port=$db_port;dbname=$db_name;", $db_username, $db_password, array(
|
||||||
|
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
|
||||||
PDO::ATTR_ERRMODE,
|
PDO::ATTR_ERRMODE,
|
||||||
PDO::ERRMODE_EXCEPTION
|
PDO::ERRMODE_EXCEPTION
|
||||||
));
|
));
|
||||||
|
|||||||
Reference in New Issue
Block a user