Created
July 1, 2010 02:56
-
-
Save nihen/459499 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PDOからよばれるreal_escape_stringで文字コードを考慮させたい場合は | |
$dbh = new PDO('mysql:host=localhost;dbname=sandbox;charset=cp932', 'sandbox', 'sandbox', array( | |
PDO::MYSQL_ATTR_READ_DEFAULT_FILE => '/etc/mysql/my.cnf', | |
PDO::MYSQL_ATTR_READ_DEFAULT_GROUP => 'client', | |
)); | |
もしくはserver-side-prepareを使う場合(文字コード気にしなくておk) | |
$dbh = new PDO('mysql:host=localhost;dbname=sandbox;charset=cp932', 'sandbox', 'sandbox', array( | |
PDO::ATTR_EMULATE_PREPARES => false, | |
)); | |
ちなむと前者は接続時に使われるオプションなのでnew PDOしたあとにあとから | |
$dbh->setAttribute | |
しても、ダメ。後者はおk。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment