mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
Merge pull request #2379 from rspenc29/2.5
Added support for passing additional flags to mysql connection
This commit is contained in:
commit
edc6fc6701
6 changed files with 18 additions and 8 deletions
|
@ -58,6 +58,9 @@
|
||||||
* For MySQL : http://dev.mysql.com/doc/refman/5.6/en/set-statement.html
|
* 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 Postgres : http://www.postgresql.org/docs/9.2/static/sql-set.html
|
||||||
* For Sql Server : http://msdn.microsoft.com/en-us/library/ms190356.aspx
|
* 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 {
|
class DATABASE_CONFIG {
|
||||||
|
|
||||||
|
|
|
@ -41,12 +41,15 @@
|
||||||
*
|
*
|
||||||
* unix_socket =>
|
* unix_socket =>
|
||||||
* For MySQL to connect via socket specify the `unix_socket` parameter instead of `host` and `port`
|
* For MySQL to connect via socket specify the `unix_socket` parameter instead of `host` and `port`
|
||||||
|
*
|
||||||
* settings =>
|
* settings =>
|
||||||
* Array of key/value pairs, on connection it executes SET statements for each pair
|
* 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 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 Postgres : http://www.postgresql.org/docs/9.2/static/sql-set.html
|
||||||
* For Sql Server : http://msdn.microsoft.com/en-us/library/ms190356.aspx
|
* 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 {
|
class DATABASE_CONFIG {
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,8 @@ class Mysql extends DboSource {
|
||||||
'login' => 'root',
|
'login' => 'root',
|
||||||
'password' => '',
|
'password' => '',
|
||||||
'database' => 'cake',
|
'database' => 'cake',
|
||||||
'port' => '3306'
|
'port' => '3306',
|
||||||
|
'flags' => array()
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -145,7 +146,7 @@ class Mysql extends DboSource {
|
||||||
$config = $this->config;
|
$config = $this->config;
|
||||||
$this->connected = false;
|
$this->connected = false;
|
||||||
|
|
||||||
$flags = array(
|
$flags = $config['flags'] + array(
|
||||||
PDO::ATTR_PERSISTENT => $config['persistent'],
|
PDO::ATTR_PERSISTENT => $config['persistent'],
|
||||||
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
|
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
|
||||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
|
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
|
||||||
|
|
|
@ -45,7 +45,8 @@ class Postgres extends DboSource {
|
||||||
'database' => 'cake',
|
'database' => 'cake',
|
||||||
'schema' => 'public',
|
'schema' => 'public',
|
||||||
'port' => 5432,
|
'port' => 5432,
|
||||||
'encoding' => ''
|
'encoding' => '',
|
||||||
|
'flags' => array()
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -110,7 +111,7 @@ class Postgres extends DboSource {
|
||||||
$config = $this->config;
|
$config = $this->config;
|
||||||
$this->connected = false;
|
$this->connected = false;
|
||||||
|
|
||||||
$flags = array(
|
$flags = $config['flags'] + array(
|
||||||
PDO::ATTR_PERSISTENT => $config['persistent'],
|
PDO::ATTR_PERSISTENT => $config['persistent'],
|
||||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
|
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
|
||||||
);
|
);
|
||||||
|
|
|
@ -56,7 +56,8 @@ class Sqlite extends DboSource {
|
||||||
*/
|
*/
|
||||||
protected $_baseConfig = array(
|
protected $_baseConfig = array(
|
||||||
'persistent' => false,
|
'persistent' => false,
|
||||||
'database' => null
|
'database' => null,
|
||||||
|
'flags' => array()
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -106,7 +107,7 @@ class Sqlite extends DboSource {
|
||||||
*/
|
*/
|
||||||
public function connect() {
|
public function connect() {
|
||||||
$config = $this->config;
|
$config = $this->config;
|
||||||
$flags = array(
|
$flags = $config['flags'] + array(
|
||||||
PDO::ATTR_PERSISTENT => $config['persistent'],
|
PDO::ATTR_PERSISTENT => $config['persistent'],
|
||||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
|
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
|
||||||
);
|
);
|
||||||
|
|
|
@ -78,6 +78,7 @@ class Sqlserver extends DboSource {
|
||||||
'password' => '',
|
'password' => '',
|
||||||
'database' => 'cake',
|
'database' => 'cake',
|
||||||
'schema' => '',
|
'schema' => '',
|
||||||
|
'flags' => array()
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -119,7 +120,7 @@ class Sqlserver extends DboSource {
|
||||||
$config = $this->config;
|
$config = $this->config;
|
||||||
$this->connected = false;
|
$this->connected = false;
|
||||||
|
|
||||||
$flags = array(
|
$flags = $config['flags'] + array(
|
||||||
PDO::ATTR_PERSISTENT => $config['persistent'],
|
PDO::ATTR_PERSISTENT => $config['persistent'],
|
||||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
|
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue