ccou...@gmail.com
unread,Apr 30, 2015, 8:09:12 AM4/30/15Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to caucho-...@googlegroups.com
I've spent quite some time trying to get UTF8 support on a PDO object, but so far no results.
When using mysqli_connect() I have no problems, but with PDO it's like there's no way to do that!?
I've tried both ways:
$dbh = mysqli_connect($db2_host, $db2_user, $db2_pass, $db2_name);
$dbh->set_charset("utf8");
if ($result = mysqli_query ( $db2, query )) {
while ( $r = mysqli_fetch_object ( $result ) ) {
echo "client: " . $r->id . " - " . $r->name;
}
}
$dbh = new PDO("mysql:host=$db2_host;dbname=$db2_name;", $db2_user, $db2_pass, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
$dbh->exec("SET NAMES utf8");
if ($sql->execute ()) {
$sql->setFetchMode ( PDO::FETCH_ASSOC );
}
while($row = $sql->fetch()) {
echo $row['id'];
echo $row['name'];
}
While using mysqli_connect() I get UTF8 results (with accents like éè...), the PDO version shows only �
Can anyone help me fix this or point me what I'm doing wrong?
I tried also rebuilding quercus.jar from scratch, added this to the Mysqli object inside PDO:
mysqli.set_charset(env, StringValue.create("utf8").toStringValue());
But this didn't help either!?
Please help.