From 6981a24b9c41c577d9c47e7e53c094fbecbb6b38 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 25 Aug 2013 21:40:39 +0200 Subject: More explicit UTF-8 More explicit UTF-8 in PDO MySQL, html_entity_decode, htmlentities, and htmlspecialchars (less important) --- lib/minz/dao/Model_pdo.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'lib/minz/dao') diff --git a/lib/minz/dao/Model_pdo.php b/lib/minz/dao/Model_pdo.php index a101887d1..6efe5b30f 100755 --- a/lib/minz/dao/Model_pdo.php +++ b/lib/minz/dao/Model_pdo.php @@ -22,23 +22,29 @@ class Model_pdo { */ public function __construct () { $db = Configuration::dataBase (); + $driver_options = null; try { $type = $db['type']; if($type == 'mysql') { $string = $type . ':host=' . $db['host'] - . ';dbname=' . $db['base']; + . ';dbname=' . $db['base'] + . ';charset=utf8'; + $driver_options = array( + PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8' + ); } elseif($type == 'sqlite') { $string = $type . ':/' . PUBLIC_PATH - . '/data/' . $db['base'] . '.sqlite'; + . '/data/' . $db['base'] . '.sqlite'; //TODO: DEBUG UTF-8 http://www.siteduzero.com/forum/sujet/sqlite-connexion-utf-8-18797 } $this->bd = new PDO ( $string, $db['user'], - $db['password'] + $db['password'], + $driver_options ); $this->prefix = $db['prefix']; -- cgit v1.2.3