Commit dd285a63 authored by Benjamin Eberlei's avatar Benjamin Eberlei

DBAL-111 - Add details about charset option and remove mention of @deprecated MysqlSessionInit.

parent 625be9a8
...@@ -104,6 +104,8 @@ pdo\_mysql ...@@ -104,6 +104,8 @@ pdo\_mysql
- ``dbname`` (string): Name of the database/schema to connect to. - ``dbname`` (string): Name of the database/schema to connect to.
- ``unix_socket`` (string): Name of the socket used to connect to - ``unix_socket`` (string): Name of the socket used to connect to
the database. the database.
- ``charset`` (string): The charset used when connecting to the
database.
pdo\_pgsql pdo\_pgsql
^^^^^^^^^^ ^^^^^^^^^^
......
...@@ -18,16 +18,12 @@ connection management via an instance of ...@@ -18,16 +18,12 @@ connection management via an instance of
``Doctrine\DBAL\Event\ConnectionEventArgs`` event arguments ``Doctrine\DBAL\Event\ConnectionEventArgs`` event arguments
instance. instance.
Doctrine is already shipped with two implementations for the Doctrine ships with one implementation for the "PostConnect" event:
"PostConnect" event:
- ``Doctrine\DBAL\Event\Listeners\OracleSessionInit`` allows to - ``Doctrine\DBAL\Event\Listeners\OracleSessionInit`` allows to
specify any number of Oracle Session related enviroment variables specify any number of Oracle Session related enviroment variables
that are set right after the connection is established. that are set right after the connection is established.
- ``Doctrine\DBAL\Event\Listeners\MysqlSessionInit`` allows to
specify the Charset and Collation of the Client Connection if these
options are not configured correctly on the MySQL server side.
You can register events by subscribing them to the ``EventManager`` You can register events by subscribing them to the ``EventManager``
instance passed to the Connection factory: instance passed to the Connection factory:
...@@ -36,7 +32,9 @@ instance passed to the Connection factory: ...@@ -36,7 +32,9 @@ instance passed to the Connection factory:
<?php <?php
$evm = new EventManager(); $evm = new EventManager();
$evm->addEventSubscriber(new MysqlSessionInit('UTF8')); $evm->addEventSubscriber(new OracleSessionInit(array(
'NLS_TIME_FORMAT' => 'HH24:MI:SS',
));
$conn = DriverManager::getConnection($connectionParams, null, $evm); $conn = DriverManager::getConnection($connectionParams, null, $evm);
......
...@@ -128,4 +128,12 @@ Non-ASCII compatible Charsets in MySQL ...@@ -128,4 +128,12 @@ Non-ASCII compatible Charsets in MySQL
Up until PHP 5.3.6 PDO has a security problem when using non ascii compatible charsets. Even if specifying Up until PHP 5.3.6 PDO has a security problem when using non ascii compatible charsets. Even if specifying
the charset using "SET NAMES", emulated prepared statements and ``PDO#quote`` could not reliably escape the charset using "SET NAMES", emulated prepared statements and ``PDO#quote`` could not reliably escape
values, opening up to potential SQL injections. If you are running PHP 5.3.6 you can solve this issue values, opening up to potential SQL injections. If you are running PHP 5.3.6 you can solve this issue
by passing the driver option "charset" to Doctrine PDO MySQL driver. Using SET NAMES does not suffice! by passing the driver option "charset" to Doctrine PDO MySQL driver. Using SET NAMES does not suffice!
\ No newline at end of file
.. code-block::
<?php
$conn = DriverManager::getConnection(array(
'driver' => 'pdo_mysql',
'charset' => 'UTF8',
));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment