summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Newnham <mark@newnhams.com>2020-12-06 13:27:10 -0700
committerMark Newnham <mark@newnhams.com>2020-12-06 13:27:10 -0700
commit26bc13472dd43471af319b70fbb96d57f20b8f27 (patch)
treecd20610bfd36e4beb76b4f770a408a46ad381d8d
parentea78b36bfd73b8ec2c1a5bdc9dfa470bbd294c16 (diff)
downloadadodb-26bc13472dd43471af319b70fbb96d57f20b8f27.tar.gz
adodb-26bc13472dd43471af319b70fbb96d57f20b8f27.tar.bz2
adodb-26bc13472dd43471af319b70fbb96d57f20b8f27.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.php19
1 files changed, 17 insertions, 2 deletions
diff --git a/drivers/adodb-pdo.inc.php b/drivers/adodb-pdo.inc.php
index 075e9189..8ee8bb31 100644
--- a/drivers/adodb-pdo.inc.php
+++ b/drivers/adodb-pdo.inc.php
@@ -86,7 +86,14 @@ 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 __construct()
{
}
@@ -148,8 +155,16 @@ 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;