Add timeout parameter for database connection
This commit is contained in:
@@ -102,6 +102,10 @@ class Mysql extends Base
|
||||
$options[PDO::ATTR_PERSISTENT] = $settings['persistent'];
|
||||
}
|
||||
|
||||
if (! empty($settings['timeout'])) {
|
||||
$options[PDO::ATTR_TIMEOUT] = $settings['timeout'];
|
||||
}
|
||||
|
||||
if (isset($settings['verify_server_cert'])) {
|
||||
$options[PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT] = $settings['verify_server_cert'];
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ class Postgres extends Base
|
||||
$dsn = 'pgsql:dbname='.$settings['database'];
|
||||
$username = null;
|
||||
$password = null;
|
||||
$options = array();
|
||||
|
||||
if (! empty($settings['username'])) {
|
||||
$username = $settings['username'];
|
||||
@@ -59,7 +60,11 @@ class Postgres extends Base
|
||||
$dsn .= ';port='.$settings['port'];
|
||||
}
|
||||
|
||||
$this->pdo = new PDO($dsn, $username, $password);
|
||||
if (! empty($settings['timeout'])) {
|
||||
$options[PDO::ATTR_TIMEOUT] = $settings['timeout'];
|
||||
}
|
||||
|
||||
$this->pdo = new PDO($dsn, $username, $password, $options);
|
||||
|
||||
if (isset($settings['schema_table'])) {
|
||||
$this->schemaTable = $settings['schema_table'];
|
||||
|
||||
@@ -29,7 +29,13 @@ class Sqlite extends Base
|
||||
*/
|
||||
public function createConnection(array $settings)
|
||||
{
|
||||
$this->pdo = new PDO('sqlite:'.$settings['filename']);
|
||||
$options = array();
|
||||
|
||||
if (! empty($settings['timeout'])) {
|
||||
$options[PDO::ATTR_TIMEOUT] = $settings['timeout'];
|
||||
}
|
||||
|
||||
$this->pdo = new PDO('sqlite:'.$settings['filename'], null, null, $options);
|
||||
$this->enableForeignKeys();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user