Come da titolo trovo problemi a impostare PDO in utf-8, qualunque aiuto e ben accetto. Nota* solo decommentando SET CHARACTER SET funziona, perché?
Codice PHP:
<?php
//>=php 5.3.6
try {
header('Content-type: text/plain; charset=utf-8');
$user = '';
$pass ='';
$db = 'my_nick';
$dbh = new PDO("mysql:host=localhost;dbname=$db;charset=utf8",$user, $pass,array (PDO::MYSQL_ATTR_INIT_COMMAND => "SET character_set_client = 'utf8',character_set_connection = 'utf8',character_set_results = 'utf8'"));
//$dbh->query('SET CHARACTER SET utf8');
$dbh->exec("CREATE TABLE IF NOT EXISTS `$db`.`tabella2` (
`campo` varchar(4) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
foreach($dbh->query("show variables like 'character\_set\_%'",PDO::FETCH_ASSOC) as $conf) {
print_r($conf);
}
$dbh = null;
} catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "\n";
die();
}
?>