diff options
| author | Mark Newnham <mark@newnhams.com> | 2020-12-06 13:14:18 -0700 |
|---|---|---|
| committer | Mark Newnham <mark@newnhams.com> | 2020-12-06 13:14:18 -0700 |
| commit | 93b3a8da091eb617f607f8b220be62d4fb7c7981 (patch) | |
| tree | 8c856b4dd3b7195af4688616c6a5f8b29db39c6e | |
| parent | 4d9a68a0cdaa8775f146a409cee395124eda1507 (diff) | |
| download | adodb-93b3a8da091eb617f607f8b220be62d4fb7c7981.tar.gz adodb-93b3a8da091eb617f607f8b220be62d4fb7c7981.tar.bz2 adodb-93b3a8da091eb617f607f8b220be62d4fb7c7981.zip | |
Adds support for PDO Constructor parameters see #650
The PDO driver now supports persistent connections via the **pconnect()** method as well as other constuctor options via the **pdoOptions** class variable. See the ADOdb PDO documentation for more information.
| -rw-r--r-- | drivers/adodb-pdo.inc.php | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/drivers/adodb-pdo.inc.php b/drivers/adodb-pdo.inc.php index 89ca0451..0f9fb653 100644 --- a/drivers/adodb-pdo.inc.php +++ b/drivers/adodb-pdo.inc.php @@ -85,6 +85,13 @@ class ADODB_pdo extends ADOConnection { var $dsnType = ''; var $stmt = false; var $_driver; + + /* + * Describe parameters passed directly to the PDO driver + * + * @example $db->pdoOptions = [\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION]; + */ + public $pdoParameters = array(); function _UpdatePDO() { @@ -145,8 +152,17 @@ class ADODB_pdo extends ADOConnection { $argDSN .= ';dbname='.$argDatabasename; } } + /* + * Configure for persistent connection if required, + * by adding the the pdo parameter into any provided + * ones + */ + if ($persist) { + $this->pdoParameters[\PDO::ATTR_PERSISTENT] = true; + } + try { - $this->_connectionID = new PDO($argDSN, $argUsername, $argPassword); + $this->_connectionID = new \PDO($argDSN, $argUsername, $argPassword, $this->pdoParameters); } catch (Exception $e) { $this->_connectionID = false; $this->_errorno = -1; |
