diff --git a/common.php b/common.php index 07032c9..d2b8a40 100644 --- a/common.php +++ b/common.php @@ -194,7 +194,7 @@ function Query($params = '') // Create the database connection $db = ( ! empty($params->user)) ? new $dbtype($dsn, $params->user, $params->pass, $options) - : new $dbtype($dsn); + : new $dbtype($dsn, '', '', $options); } catch(Exception $e) { diff --git a/drivers/firebird/firebird_driver.php b/drivers/firebird/firebird_driver.php index 0505894..2ff96f4 100644 --- a/drivers/firebird/firebird_driver.php +++ b/drivers/firebird/firebird_driver.php @@ -58,10 +58,18 @@ class Firebird extends DB_PDO { * @param string $dbpath * @param string $user * @param string $pass + * @param array $options */ - public function __construct($dbpath, $user='SYSDBA', $pass='masterkey') + public function __construct($dbpath, $user='SYSDBA', $pass='masterkey', $options = array()) { - $this->conn = fbird_connect($dbpath, $user, $pass, 'utf-8', 0); + if (isset($options[PDO::ATTR_PERSISTENT]) && $options[PDO::ATTR_PERSISTENT] == TRUE) + { + $this->conn = fbird_pconnect($dbpath, $user, $pass, 'utf-8', 0); + } + else + { + $this->conn = fbird_connect($dbpath, $user, $pass, 'utf-8', 0); + } // Throw an exception to make this match other pdo classes if ( ! is_resource($this->conn)) throw new PDOException(fbird_errmsg()); diff --git a/tests/core/db_qb_test.php b/tests/core/db_qb_test.php index e69bcd3..8bda322 100644 --- a/tests/core/db_qb_test.php +++ b/tests/core/db_qb_test.php @@ -607,9 +607,9 @@ abstract class QBTest extends Query_TestCase { public function testUpdate() { - $query = $this->db->where('id', 4) + $query = $this->db->where('id', 7) ->update('create_test', array( - 'id' => 4, + 'id' => 7, 'key' => 'gogle', 'val' => 'non-word' )); @@ -622,13 +622,13 @@ abstract class QBTest extends Query_TestCase { public function testSetArrayUpdate() { $array = array( - 'id' => 4, + 'id' => 22, 'key' => 'gogle', 'val' => 'non-word' ); $query = $this->db->set($array) - ->where('id', 4) + ->where('id', 22) ->update('create_test'); $this->assertIsA($query, 'PDOStatement'); @@ -638,8 +638,8 @@ abstract class QBTest extends Query_TestCase { public function testWhereSetUpdate() { - $query = $this->db->where('id', 4) - ->set('id', 4) + $query = $this->db->where('id', 36) + ->set('id', 36) ->set('key', 'gogle') ->set('val', 'non-word') ->update('test'); @@ -651,7 +651,7 @@ abstract class QBTest extends Query_TestCase { public function testDelete() { - $query = $this->db->delete('create_test', array('id' => 4)); + $query = $this->db->delete('create_test', array('id' => 5)); $this->assertIsA($query, 'PDOStatement'); } diff --git a/tests/databases/firebird/FirebirdQBTest.php b/tests/databases/firebird/FirebirdQBTest.php index a473f50..0ad8aa4 100644 --- a/tests/databases/firebird/FirebirdQBTest.php +++ b/tests/databases/firebird/FirebirdQBTest.php @@ -22,6 +22,11 @@ class FirebirdQBTest extends QBTest { public function setUp() { $dbpath = QTEST_DIR.QDS.'db_files'.QDS.'FB_TEST_DB.FDB'; + + if ( ! function_exists('fbird_connect')) + { + $this->markTestSkipped('Firebird extension does not exist'); + } // test the query builder $params = new Stdclass(); @@ -32,6 +37,8 @@ class FirebirdQBTest extends QBTest { $params->user = 'sysdba'; $params->pass = 'masterkey'; $params->prefix = 'create_'; + $params->options = array(); + $params->options[PDO::ATTR_PERSISTENT] = TRUE; $this->db = Query($params); } @@ -63,7 +70,7 @@ class FirebirdQBTest extends QBTest { $params->host = 'localhost'; $params->user = 'sysdba'; $params->pass = 'masterkey'; - $params->prefix = 'create_'; + $params->prefix = ''; $f_conn = Query($params); $this->assertReference($f_conn, Query('fire')); @@ -142,5 +149,4 @@ class FirebirdQBTest extends QBTest { // Queries are equal because explain is not a keyword in Firebird $this->assertEqual($res, $res2); } - } \ No newline at end of file diff --git a/tests/databases/mysql/MySQLQBTest.php b/tests/databases/mysql/MySQLQBTest.php index 16349f0..6bed5c7 100644 --- a/tests/databases/mysql/MySQLQBTest.php +++ b/tests/databases/mysql/MySQLQBTest.php @@ -26,7 +26,9 @@ class MySQLQBTest extends QBTest { $params = json_decode(file_get_contents(QBASE_DIR . "test_config.json")); $params = $params->mysql; $params->type = "MySQL"; - $params->prefix = "create_";; + $params->prefix = "create_"; + $params->options = array(); + $params->options[PDO::ATTR_PERSISTENT] = TRUE; } elseif (($var = getenv('CI'))) // Travis CI Connection Info { @@ -43,11 +45,6 @@ class MySQLQBTest extends QBTest { $this->db = Query($params); } - - public function testWhereSetUpdate() {} - public function testDelete() {} - public function testSetArrayUpdate() {} - public function testUpdate() {} // -------------------------------------------------------------------------- diff --git a/tests/databases/pgsql/PgSQLQBTest.php b/tests/databases/pgsql/PgSQLQBTest.php index a176799..f301b60 100644 --- a/tests/databases/pgsql/PgSQLQBTest.php +++ b/tests/databases/pgsql/PgSQLQBTest.php @@ -22,7 +22,7 @@ class PgSQLQBTest extends QBTest { // If the database isn't installed, skip the tests if ( ! class_exists("PgSQL")) { - $this->markTestSkipped(); + $this->markTestSkipped("Postgres extension for PDO not loaded"); } // Attempt to connect, if there is a test config file @@ -32,6 +32,8 @@ class PgSQLQBTest extends QBTest { $params = $params->pgsql; $params->type = "pgsql"; $params->prefix = 'create_'; + $params->options = array(); + $params->options[PDO::ATTR_PERSISTENT] = TRUE; } elseif (($var = getenv('CI'))) // Travis CI Connection Info { diff --git a/tests/databases/pgsql/PgSQLTest.php b/tests/databases/pgsql/PgSQLTest.php index e9572e5..8be2ffe 100644 --- a/tests/databases/pgsql/PgSQLTest.php +++ b/tests/databases/pgsql/PgSQLTest.php @@ -26,7 +26,7 @@ class PgTest extends DBTest { // If the database isn't installed, skip the tests if ( ! class_exists("PgSQL")) { - $this->markTestSkipped(); + $this->markTestSkipped("Postgres extension for PDO not loaded"); } // Attempt to connect, if there is a test config file diff --git a/tests/databases/sqlite/SqliteQBTest.php b/tests/databases/sqlite/SqliteQBTest.php index 42fe9ca..1a148cb 100644 --- a/tests/databases/sqlite/SqliteQBTest.php +++ b/tests/databases/sqlite/SqliteQBTest.php @@ -27,6 +27,8 @@ $params->file = $path; $params->host = 'localhost'; $params->prefix = 'create_'; + $params->options = array(); + $params->options[PDO::ATTR_PERSISTENT] = TRUE; $this->db = Query($params); // echo '
SQLite Queries
';