Add timeout parameter for database connection
This commit is contained in:
parent
b096e907cf
commit
0d578171fe
|
|
@ -136,6 +136,7 @@ class DatabaseProvider implements ServiceProviderInterface
|
|||
'ssl_ca' => DB_SSL_CA,
|
||||
'ssl_cert' => DB_SSL_CERT,
|
||||
'verify_server_cert' => DB_VERIFY_SERVER_CERT,
|
||||
'timeout' => DB_TIMEOUT,
|
||||
));
|
||||
}
|
||||
|
||||
|
|
@ -156,6 +157,7 @@ class DatabaseProvider implements ServiceProviderInterface
|
|||
'password' => DB_PASSWORD,
|
||||
'database' => DB_NAME,
|
||||
'port' => DB_PORT,
|
||||
'timeout' => DB_TIMEOUT,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ defined('DB_SSL_KEY') or define('DB_SSL_KEY', null);
|
|||
defined('DB_SSL_CERT') or define('DB_SSL_CERT', null);
|
||||
defined('DB_SSL_CA') or define('DB_SSL_CA', null);
|
||||
defined('DB_VERIFY_SERVER_CERT') or define('DB_VERIFY_SERVER_CERT', null);
|
||||
defined('DB_TIMEOUT') or define('DB_TIMEOUT', null);
|
||||
|
||||
// Database backend group provider
|
||||
defined('DB_GROUP_PROVIDER') or define('DB_GROUP_PROVIDER', true);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
"eluceo/ical": "0.10.1",
|
||||
"erusev/parsedown" : "1.6.0",
|
||||
"fguillot/json-rpc" : "1.2.1",
|
||||
"fguillot/picodb" : "1.0.16",
|
||||
"fguillot/picodb" : "1.0.17",
|
||||
"fguillot/simpleLogger" : "1.0.1",
|
||||
"fguillot/simple-validator" : "1.0.1",
|
||||
"fguillot/simple-queue" : "1.0.1",
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "100bd25a2613fac1b666b2103be0f3ce",
|
||||
"content-hash": "6d59b34b5598ac4a46c73dce19772b9b",
|
||||
"packages": [
|
||||
{
|
||||
"name": "aferrandini/phpqrcode",
|
||||
|
|
@ -288,16 +288,16 @@
|
|||
},
|
||||
{
|
||||
"name": "fguillot/picodb",
|
||||
"version": "v1.0.16",
|
||||
"version": "v1.0.17",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/fguillot/picoDb.git",
|
||||
"reference": "03b89d09e283cbaffbb4039e4ba6eaa3d327002a"
|
||||
"reference": "1699864992c40ad02395e95d7fbf44a571a116f3"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/fguillot/picoDb/zipball/03b89d09e283cbaffbb4039e4ba6eaa3d327002a",
|
||||
"reference": "03b89d09e283cbaffbb4039e4ba6eaa3d327002a",
|
||||
"url": "https://api.github.com/repos/fguillot/picoDb/zipball/1699864992c40ad02395e95d7fbf44a571a116f3",
|
||||
"reference": "1699864992c40ad02395e95d7fbf44a571a116f3",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -324,7 +324,7 @@
|
|||
],
|
||||
"description": "Minimalist database query builder",
|
||||
"homepage": "https://github.com/fguillot/picoDb",
|
||||
"time": "2018-01-30T00:01:16+00:00"
|
||||
"time": "2018-02-14T00:51:01+00:00"
|
||||
},
|
||||
{
|
||||
"name": "fguillot/simple-queue",
|
||||
|
|
@ -1294,16 +1294,16 @@
|
|||
},
|
||||
{
|
||||
"name": "phpspec/prophecy",
|
||||
"version": "1.7.3",
|
||||
"version": "1.7.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpspec/prophecy.git",
|
||||
"reference": "e4ed002c67da8eceb0eb8ddb8b3847bb53c5c2bf"
|
||||
"reference": "9f901e29c93dae4aa77c0bb161df4276f9c9a1be"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/e4ed002c67da8eceb0eb8ddb8b3847bb53c5c2bf",
|
||||
"reference": "e4ed002c67da8eceb0eb8ddb8b3847bb53c5c2bf",
|
||||
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/9f901e29c93dae4aa77c0bb161df4276f9c9a1be",
|
||||
"reference": "9f901e29c93dae4aa77c0bb161df4276f9c9a1be",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -1315,7 +1315,7 @@
|
|||
},
|
||||
"require-dev": {
|
||||
"phpspec/phpspec": "^2.5|^3.2",
|
||||
"phpunit/phpunit": "^4.8.35 || ^5.7"
|
||||
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
|
|
@ -1353,7 +1353,7 @@
|
|||
"spy",
|
||||
"stub"
|
||||
],
|
||||
"time": "2017-11-24T13:59:53+00:00"
|
||||
"time": "2018-02-11T18:49:29+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-code-coverage",
|
||||
|
|
|
|||
|
|
@ -88,6 +88,9 @@ define('DB_SSL_CA', null);
|
|||
// Mysql SSL server verification, set to false if you don't want the Mysql driver to validate the certificate CN
|
||||
define('DB_VERIFY_SERVER_CERT', null);
|
||||
|
||||
// Timeout value for PDO attribute
|
||||
define('DB_TIMEOUT', null);
|
||||
|
||||
// Enable LDAP authentication (false by default)
|
||||
define('LDAP_AUTH', false);
|
||||
|
||||
|
|
|
|||
|
|
@ -291,48 +291,6 @@
|
|||
"description": "Simple Json-RPC client/server library that just works",
|
||||
"homepage": "https://github.com/fguillot/JsonRPC"
|
||||
},
|
||||
{
|
||||
"name": "fguillot/picodb",
|
||||
"version": "v1.0.16",
|
||||
"version_normalized": "1.0.16.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/fguillot/picoDb.git",
|
||||
"reference": "03b89d09e283cbaffbb4039e4ba6eaa3d327002a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/fguillot/picoDb/zipball/03b89d09e283cbaffbb4039e4ba6eaa3d327002a",
|
||||
"reference": "03b89d09e283cbaffbb4039e4ba6eaa3d327002a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "4.8.*"
|
||||
},
|
||||
"time": "2018-01-30T00:01:16+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"PicoDb": "lib/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Frédéric Guillot",
|
||||
"homepage": "https://github.com/fguillot/"
|
||||
}
|
||||
],
|
||||
"description": "Minimalist database query builder",
|
||||
"homepage": "https://github.com/fguillot/picoDb"
|
||||
},
|
||||
{
|
||||
"name": "fguillot/simple-queue",
|
||||
"version": "v1.0.1",
|
||||
|
|
@ -1079,5 +1037,47 @@
|
|||
],
|
||||
"description": "Symfony EventDispatcher Component",
|
||||
"homepage": "https://symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "fguillot/picodb",
|
||||
"version": "v1.0.17",
|
||||
"version_normalized": "1.0.17.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/fguillot/picoDb.git",
|
||||
"reference": "1699864992c40ad02395e95d7fbf44a571a116f3"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/fguillot/picoDb/zipball/1699864992c40ad02395e95d7fbf44a571a116f3",
|
||||
"reference": "1699864992c40ad02395e95d7fbf44a571a116f3",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "4.8.*"
|
||||
},
|
||||
"time": "2018-02-14T00:51:01+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"PicoDb": "lib/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Frédéric Guillot",
|
||||
"homepage": "https://github.com/fguillot/"
|
||||
}
|
||||
],
|
||||
"description": "Minimalist database query builder",
|
||||
"homepage": "https://github.com/fguillot/picoDb"
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue