Skip to content

Commit ef77493

Browse files
committed
Allow passing in of PDO startup options.
1 parent 3cfd287 commit ef77493

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/PHPQueue/Backend/PDO.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class PDO extends Base
99
private $db_user;
1010
private $db_password;
1111
private $db_table;
12+
private $pdo_options = array();
1213

1314
public function __construct($options=array())
1415
{
@@ -25,6 +26,9 @@ public function __construct($options=array())
2526
if (!empty($options['db_table'])) {
2627
$this->db_table = $options['db_table'];
2728
}
29+
if (!empty($options['pdo_options']) && is_array($options['pdo_options'])) {
30+
$this->pdo_options = array_merge($this->pdo_options, $options['pdo_options']);
31+
}
2832
}
2933

3034
public function setTable($table_name=null)
@@ -39,7 +43,7 @@ public function setTable($table_name=null)
3943

4044
public function connect()
4145
{
42-
$this->connection = new \PDO($this->connection_string, $this->db_user, $this->db_password);
46+
$this->connection = new \PDO($this->connection_string, $this->db_user, $this->db_password, $this->pdo_options);
4347
}
4448

4549
public function add($data = null)

test/PHPQueue/Backend/PDOTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ public function setUp()
1818
, 'db_user' => 'root'
1919
, 'db_password' => 'media1'
2020
, 'db_table' => 'pdotest'
21+
, 'pdo_options' => array(
22+
\PDO::ATTR_PERSISTENT => true
23+
)
2124
);
2225
$this->object = new PDO($options);
2326
}

0 commit comments

Comments
 (0)