From 61a61fc285bad4452ddf3d4c5859c4cd613e806b Mon Sep 17 00:00:00 2001 From: Tobsn Date: Fri, 22 Jun 2012 06:06:54 -0700 Subject: [PATCH] Added explanation about PDO default attributes regarding issue #788 https://github.com/laravel/laravel/issues/788 --- laravel/documentation/database/config.md | 26 +++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/laravel/documentation/database/config.md b/laravel/documentation/database/config.md index a4eddb62..3768f013 100644 --- a/laravel/documentation/database/config.md +++ b/laravel/documentation/database/config.md @@ -5,6 +5,7 @@ ## Contents - [Quick Start Using SQLite](#quick) - [Configuring Other Databases](#server) - [Setting The Default Connection Name](#default) +- [Overwriting The Default PDO Options](#options) Laravel supports the following databases out of the box: @@ -43,4 +44,27 @@ ## Setting The Default Connection Name 'default' => 'sqlite'; -The default connection will always be used by the [fluent query builder](/docs/database/fluent). If you need to change the default connection during a request, use the **Config::set** method. \ No newline at end of file +The default connection will always be used by the [fluent query builder](/docs/database/fluent). If you need to change the default connection during a request, use the **Config::set** method. + + +##Overwriting The Default PDO Options + +The PDO connecter class (**laravel/database/connectors/connector.php**) has a set of default PDO attributes defined which can be overwritten in the options array for each system. For example, one of the default attributes is to force column names to lowercase (**PDO::CASE_LOWER**) even if they are defined in UPPERCASE or CamelCase in the table. Therefor, under the default attributes, query result object variables would only be accessible in lowercase. +An example of the MySQL system settings with added default PDO attributes: + + 'mysql' => array( + 'driver' => 'mysql', + 'host' => 'localhost', + 'database' => 'database', + 'username' => 'root', + 'password' => '', + 'charset' => 'utf8', + 'prefix' => '', + PDO::ATTR_CASE => PDO::CASE_LOWER, + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::ATTR_ORACLE_NULLS => PDO::NULL_NATURAL, + PDO::ATTR_STRINGIFY_FETCHES => false, + PDO::ATTR_EMULATE_PREPARES => false, + ), + +More about the PDO connection attributes can be found [here](http://php.net/manual/en/pdo.setattribute.php). \ No newline at end of file