From cda9320e969c90e718b1581054efc1b095efa523 Mon Sep 17 00:00:00 2001 From: Rob Spencer Date: Thu, 21 Nov 2013 21:35:29 -0500 Subject: [PATCH] Added support for passing additional flags to mysql connection --- app/Config/database.php.default | 3 +++ lib/Cake/Console/Templates/skel/Config/database.php.default | 5 ++++- lib/Cake/Model/Datasource/Database/Mysql.php | 5 +++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/Config/database.php.default b/app/Config/database.php.default index 42fedb60a..767c01095 100644 --- a/app/Config/database.php.default +++ b/app/Config/database.php.default @@ -58,6 +58,9 @@ * For MySQL : http://dev.mysql.com/doc/refman/5.6/en/set-statement.html * For Postgres : http://www.postgresql.org/docs/9.2/static/sql-set.html * For Sql Server : http://msdn.microsoft.com/en-us/library/ms190356.aspx + * + * flags => + * A key/value array of driver specific connection options. */ class DATABASE_CONFIG { diff --git a/lib/Cake/Console/Templates/skel/Config/database.php.default b/lib/Cake/Console/Templates/skel/Config/database.php.default index fdefd4161..00ad15507 100644 --- a/lib/Cake/Console/Templates/skel/Config/database.php.default +++ b/lib/Cake/Console/Templates/skel/Config/database.php.default @@ -41,12 +41,15 @@ * * unix_socket => * For MySQL to connect via socket specify the `unix_socket` parameter instead of `host` and `port` - + * * settings => * Array of key/value pairs, on connection it executes SET statements for each pair * For MySQL : http://dev.mysql.com/doc/refman/5.6/en/set-statement.html * For Postgres : http://www.postgresql.org/docs/9.2/static/sql-set.html * For Sql Server : http://msdn.microsoft.com/en-us/library/ms190356.aspx + * + * flags => + * A key/value array of driver specific connection options. */ class DATABASE_CONFIG { diff --git a/lib/Cake/Model/Datasource/Database/Mysql.php b/lib/Cake/Model/Datasource/Database/Mysql.php index d2b53d561..4f1d16819 100644 --- a/lib/Cake/Model/Datasource/Database/Mysql.php +++ b/lib/Cake/Model/Datasource/Database/Mysql.php @@ -45,7 +45,8 @@ class Mysql extends DboSource { 'login' => 'root', 'password' => '', 'database' => 'cake', - 'port' => '3306' + 'port' => '3306', + 'flags' => array() ); /** @@ -145,7 +146,7 @@ class Mysql extends DboSource { $config = $this->config; $this->connected = false; - $flags = array( + $flags = $config['flags'] + array( PDO::ATTR_PERSISTENT => $config['persistent'], PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION