Looking at here: http://www.php.net/manual/en/mysqlinfo.concepts.charset.php
I understand that using
SET NAMES utf8
is not a good idea, but it is not clear:
- What is the issue?
- How to avoid it?
- Which is actually the solution to set the charset for a (or all) PDO connection(s) in a PHP 3.6 or higher?
The code I'm afraid is dangerous:
$this->_conn = new PDO('mysql:host=host.name.blabla;dbname=my_database_name','username', 'password',array(
PDO::ATTR_PERSISTENT => true,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'
));
Thanks!