Merge pull request #2379 from rspenc29/2.5

Added support for passing additional flags to mysql connection
This commit is contained in:
José Lorenzo Rodríguez 2013-11-24 01:07:58 -08:00
commit edc6fc6701
6 changed files with 18 additions and 8 deletions

View file

@ -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 {

View file

@ -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 {

View file

@ -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

View file

@ -45,7 +45,8 @@ class Postgres extends DboSource {
'database' => 'cake',
'schema' => 'public',
'port' => 5432,
'encoding' => ''
'encoding' => '',
'flags' => array()
);
/**
@ -110,7 +111,7 @@ class Postgres extends DboSource {
$config = $this->config;
$this->connected = false;
$flags = array(
$flags = $config['flags'] + array(
PDO::ATTR_PERSISTENT => $config['persistent'],
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
);

View file

@ -56,7 +56,8 @@ class Sqlite extends DboSource {
*/
protected $_baseConfig = array(
'persistent' => false,
'database' => null
'database' => null,
'flags' => array()
);
/**
@ -106,7 +107,7 @@ class Sqlite extends DboSource {
*/
public function connect() {
$config = $this->config;
$flags = array(
$flags = $config['flags'] + array(
PDO::ATTR_PERSISTENT => $config['persistent'],
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
);

View file

@ -78,6 +78,7 @@ class Sqlserver extends DboSource {
'password' => '',
'database' => 'cake',
'schema' => '',
'flags' => array()
);
/**
@ -119,7 +120,7 @@ class Sqlserver extends DboSource {
$config = $this->config;
$this->connected = false;
$flags = array(
$flags = $config['flags'] + array(
PDO::ATTR_PERSISTENT => $config['persistent'],
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
);