MySQL Native Driver (
Mysqlnd
)
2524
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
);
$dbh = new PDO($dsn, $username, $password, $options);
?>
Changelog
Version
Description
5.3.6
Prior to version 5.3.6,
charset
was ignored.
Examples
Example 20.214. PDO_MYSQL DSN examples
The following example shows a PDO_MYSQL DSN for connecting to MySQL databases:
mysql:host=localhost;dbname=testdb
More complete examples:
mysql:host=localhost;port=3307;dbname=testdb
mysql:unix_socket=/tmp/mysql.sock;dbname=testdb
Notes
Unix only:
When the host name is set to
"localhost"
, then the connection to the
server is made thru a domain socket. If PDO_MYSQL is compiled against
libmysqlclient then the location of the socket file is at libmysqlclient's compiled in
location. If PDO_MYSQL is compiled against mysqlnd a default socket can be
set thru the
pdo_mysql.default_socket
setting.
20.7.5. MySQL Native Driver (
Mysqlnd
)
Copyright 1997-2012 the PHP Documentation Group. [2230]
MySQL Native Driver is a replacement for the MySQL Client Library (libmysqlclient). MySQL Native
Driver is part of the official PHP sources as of PHP 5.3.0.
The MySQL database extensions MySQL extension,
mysqli
and PDO MYSQL all communicate with
the MySQL server. In the past, this was done by the extension using the services provided by the
MySQL Client Library. The extensions were compiled against the MySQL Client Library in order to use
its client-server protocol.
With MySQL Native Driver there is now an alternative, as the MySQL database extensions can be
compiled to use MySQL Native Driver instead of the MySQL Client Library.
MySQL Native Driver is written in C as a PHP extension.
20.7.5.1. Overview
Copyright 1997-2012 the PHP Documentation Group. [2230]
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...