I used to have this as one of the options (4th param) passed to PDO constructor:
$aOptions[PDO::MYSQL_ATTR_INIT_COMMAND] = "SET NAMES utf8";
But just found that it does not work on certain php versions on Windows (does not work in 5.3) due to some bug.
Now I need to run SET NAMES utf8
using either $pdo->exec("SET NAMES utf8");
or $pdo->query("SET NAMES utf8");
right after the instantiating the pdo object. So, which one should I use - exec() or query()?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…