note 100414 added to pdo.connections
| From: | ekkart at ekkart dot de | Date: | Thu, 14 Oct 2010 10:43:07 +0000 |
| Subject: | note 100414 added to pdo.connections | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-173213@lists.php.net to get a copy of this message | ||
In order to set the encoding of the database connection, use the exec function:
<?php
try {
$dbh = new PDO('mysql:host=localhost;dbname=test', $user, $pass);
$dbh->exec("SET CHARACTER SET utf8");
$dbh = null;
} catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 153.97.97.36
----
Manual Page -- http://www.php.net/manual/en/pdo.connections.php
Edit -- https://master.php.net/note/edit/100414
Del: integrated -- https://master.php.net/note/delete/100414/integrated
Del: useless -- https://master.php.net/note/delete/100414/useless
Del: bad code -- https://master.php.net/note/delete/100414/bad+code
Del: spam -- https://master.php.net/note/delete/100414/spam
Del: non-english -- https://master.php.net/note/delete/100414/non-english
Del: in docs -- https://master.php.net/note/delete/100414/in+docs
Del: other reasons-- https://master.php.net/note/delete/100414
Reject -- https://master.php.net/note/reject/100414
Search -- https://master.php.net/manage/user-notes.php