Remove PDO Firebird driver

This commit is contained in:
Timothy Warren 2015-11-10 09:20:13 -05:00
parent d55a244f1a
commit a27d639b13
5 changed files with 0 additions and 491 deletions

View File

@ -1,88 +0,0 @@
<?php
/**
* Query
*
* Free Query Builder / Database Abstraction Layer
*
* @package Query
* @author Timothy J. Warren
* @copyright Copyright (c) 2012 - 2014
* @link https://github.com/aviat4ion/Query
* @license http://philsturgeon.co.uk/code/dbad-license
*/
// --------------------------------------------------------------------------
namespace Query\Drivers\Pdo_firebird;
/**
* Firebird specific class
*
* @package Query
* @subpackage Drivers
*/
class Driver extends \Query\Abstract_Driver {
/**
* Firebird doesn't have the truncate keyword
*
* @var bool
*/
protected $has_truncate = FALSE;
/**
* Connect to Firebird Database
*
* @param string $dsn
* @param string $username
* @param string $password
* @param array $options
*/
public function __construct($dsn, $username="SYSDBA", $password="masterkey", array $options=array())
{
parent::__construct($dsn, $username, $password, $options);
}
// --------------------------------------------------------------------------
/**
* Create sql for batch insert
*
* @param string $table
* @param array $data
* @return array
*/
public function insert_batch($table, $data=array())
{
// Each member of the data array needs to be an array
if ( ! is_array(current($data))) return NULL;
// Start the block of sql statements
$sql = "EXECUTE BLOCK AS BEGIN\n";
$table = $this->quote_table($table);
$fields = \array_keys(\current($data));
$insert_template = "INSERT INTO {$table} ("
. implode(',', $this->quote_ident($fields))
. ") VALUES (";
foreach($data as $item)
{
// Quote string values
$vals = array_map(array($this, 'quote'), $item);
// Add the values in the sql
$sql .= $insert_template . implode(', ', $vals) . ");\n";
}
// End the block of SQL statements
$sql .= "END";
// Return a null array value so the query is run as it is,
// not as a prepared statement, because a prepared statement
// doesn't work for this type of query in Firebird.
return array($sql, NULL);
}
}
//End of firebird_driver.php

View File

@ -1,25 +0,0 @@
<?php
/**
* Query
*
* Free Query Builder / Database Abstraction Layer
*
* @package Query
* @author Timothy J. Warren
* @copyright Copyright (c) 2012 - 2014
* @link https://github.com/aviat4ion/Query
* @license http://philsturgeon.co.uk/code/dbad-license
*/
// --------------------------------------------------------------------------
namespace Query\Drivers\Pdo_firebird;
/**
* Firebird Specific SQL
*
* @package Query
* @subpackage Drivers
*/
class SQL extends \Query\Drivers\Firebird\SQL {}
//End of firebird_sql.php

View File

@ -1,37 +0,0 @@
<?php
/**
* Query
*
* Free Query Builder / Database Abstraction Layer
*
* @package Query
* @author Timothy J. Warren
* @copyright Copyright (c) 2012 - 2014
* @link https://github.com/aviat4ion/Query
* @license http://philsturgeon.co.uk/code/dbad-license
*/
// --------------------------------------------------------------------------
namespace Query\Drivers\Pdo_firebird;
/**
* Firebird-specific backup, import and creation methods
*
* @package Query
* @subpackage Drivers
*/
class Util extends \Query\Drivers\Firebird\Util {
/**
* Create an SQL backup file for the current database's structure
* @param string $db_path
* @param string $new_file
* @return string
*/
public function backup_structure()
{
return NULL;
}
}
// End of firebird_util.php

View File

@ -1,129 +0,0 @@
<?php
/**
* Query
*
* Free Query Builder / Database Abstraction Layer
*
* @package Query
* @author Timothy J. Warren
* @copyright Copyright (c) 2012 - 2014
* @link https://github.com/aviat4ion/Query
* @license http://philsturgeon.co.uk/code/dbad-license
*/
// --------------------------------------------------------------------------
/**
* Firebird Query Builder Tests
* @requires extension interbase
*/
class PDOFirebirdQBTest extends QBTest {
public function setUp()
{
if ( ! in_array('firebird', PDO::getAvailableDrivers()))
{
$this->markTestSkipped('PDO Firebird extension does not exist');
}
$dbpath = QTEST_DIR.QDS.'db_files'.QDS.'FB_TEST_DB.FDB';
// test the query builder
$params = new Stdclass();
$params->alias = 'fire';
$params->type = 'pdo_firebird';
$params->database = $dbpath;
$params->host = 'localhost';
$params->user = 'SYSDBA';
$params->pass = 'masterkey';
$params->prefix = 'create_';
self::$db = Query($params);
}
public function testQueryFunctionAlias()
{
$this->markTestSkipped();
if (version_compare(PHP_VERSION, '7.0.0', '<='))
{
$this->markTestSkipped("Segfaults on this version of PHP");
}
$db = Query();
$this->assertTrue(self::$db === $db);
}
public function testGetNamedConnectionException()
{
try
{
$db = Query('water');
}
catch(InvalidArgumentException $e)
{
$this->assertIsA($e, 'InvalidArgumentException');
}
}
public function testGetNamedConnection()
{
$dbpath = QTEST_DIR.QDS.'db_files'.QDS.'FB_TEST_DB.FDB';
// test the query builder
$params = new Stdclass();
$params->alias = 'wood';
$params->type = 'pdo_firebird';
$params->database = $dbpath;
$params->host = 'localhost';
$params->user = 'sysdba';
$params->pass = 'masterkey';
$params->prefix = '';
$f_conn = Query($params);
$q_conn = Query('wood');
$this->assertReference($f_conn, $q_conn);
}
// --------------------------------------------------------------------------
public function testTypeList()
{
$this->markTestIncomplete();
if (version_compare(PHP_VERSION, '7.0.0', '<='))
{
$this->markTestSkipped("Segfaults on this version of PHP");
}
$this->doSetUp();
$sql = self::$db->get_sql()->type_list();
$query = self::$db->query($sql);
$this->assertIsA('PDOStatement', $query);
$res = $query->fetchAll(PDO::FETCH_ASSOC);
$this->assertTrue(is_array($res));
}
// --------------------------------------------------------------------------
public function testQueryExplain()
{
$res = self::$db->select('id, key as k, val')
->explain()
->where('id >', 1)
->where('id <', 900)
->limit(2, 1)
->get_compiled_select();
$res2 = self::$db->select('id, key as k, val')
->where('id >', 1)
->where('id <', 900)
->limit(2, 1)
->get_compiled_select();
// Queries are equal because explain is not a keyword in Firebird
$this->assertEqual($res, $res2);
}
}

View File

@ -1,212 +0,0 @@
<?php
/**
* Query
*
* Free Query Builder / Database Abstraction Layer
*
* @package Query
* @author Timothy J. Warren
* @copyright Copyright (c) 2012 - 2014
* @link https://github.com/aviat4ion/Query
* @license http://philsturgeon.co.uk/code/dbad-license
*/
// --------------------------------------------------------------------------
@chmod(QTEST_DIR.QDS.'db_files'.QDS.'FB_TEST_DB.FDB', 0777);
/**
* Firebirdtest class.
*
* @extends DBtest
* @requires extension interbase
*/
class PDOFirebirdTest extends DBtest {
public static function setUpBeforeClass()
{
$dbpath = QTEST_DIR.QDS.'db_files'.QDS.'FB_TEST_DB.FDB';
// test the db driver directly
self::$db = new \Query\Drivers\Pdo_firebird\Driver('firebird:host=localhost;dbname='.$dbpath);
self::$db->set_table_prefix('create_');
}
public function setUp()
{
if ( ! in_array('firebird', PDO::getAvailableDrivers()))
{
$this->markTestSkipped('PDO Firebird extension does not exist');
}
$this->tables = self::$db->get_tables();
}
// --------------------------------------------------------------------------
public function tearDown()
{
unset($this->tables);
}
// --------------------------------------------------------------------------
public function testExists()
{
$this->assertTrue(in_array('firebird', PDO::getAvailableDrivers()));;
}
// --------------------------------------------------------------------------
public function testConnection()
{
$this->assertIsA(self::$db, '\\Query\\Drivers\\Pdo_firebird\\Driver');
}
// --------------------------------------------------------------------------
public function testGetSystemTables()
{
$only_system = TRUE;
$tables = self::$db->get_system_tables();
foreach($tables as $t)
{
if(stripos($t, 'rdb$') !== 0 && stripos($t, 'mon$') !== 0)
{
$only_system = FALSE;
break;
}
}
$this->assertTrue($only_system);
}
public function testBackupStructure()
{
$this->assertNull(self::$db->get_util()->backup_structure());
}
// --------------------------------------------------------------------------
// ! Create / Delete Tables
// --------------------------------------------------------------------------
public function testCreateTable()
{
$this->markTestSkipped();
if (version_compare(PHP_VERSION, '7.0.0', '<='))
{
$this->markTestSkipped("Segfaults on this version of PHP");
}
//Attempt to create the table
$sql = self::$db->get_util()->create_table('create_delete', array(
'id' => 'SMALLINT',
'key' => 'VARCHAR(64)',
'val' => 'BLOB SUB_TYPE TEXT'
));
self::$db->query($sql);
//Check
$this->assertTrue(in_array('create_delete', self::$db->get_tables()));
}
// --------------------------------------------------------------------------
public function testDeleteTable()
{
$this->markTestSkipped();
if (version_compare(PHP_VERSION, '7.0.0', '<='))
{
$this->markTestSkipped("Segfaults on this version of PHP");
}
//Attempt to delete the table
$sql = self::$db->get_util()->delete_table('create_delete');
self::$db->query($sql);
//Check
$table_exists = in_array('create_delete', self::$db->get_tables());
$this->assertFalse($table_exists);
}
// --------------------------------------------------------------------------
public function testTruncate()
{
if (version_compare(PHP_VERSION, '7.0.0', '<='))
{
$this->markTestSkipped("Segfaults on this version of PHP");
}
self::$db->truncate('create_test');
$this->assertTrue(self::$db->affected_rows() > 0);
}
// --------------------------------------------------------------------------
public function testPreparedStatements()
{
$this->markTestSkipped();
/*if (version_compare(PHP_VERSION, '7.0.0', '<='))
{
$this->markTestSkipped("Segfaults on this version of PHP");
}*/
$sql = <<<SQL
INSERT INTO "create_test" ("id", "key", "val")
VALUES (?,?,?)
SQL;
$query = self::$db->prepare($sql);
$query->execute(array(1,"booger's", "Gross"));
}
// --------------------------------------------------------------------------
public function testPrepareExecute()
{
$this->markTestSkipped();
$sql = <<<SQL
INSERT INTO "create_test" ("id", "key", "val")
VALUES (?,?,?)
SQL;
self::$db->prepare_execute($sql, array(
2, "works", 'also?'
));
}
// --------------------------------------------------------------------------
public function testErrorInfo()
{
$result = self::$db->errorInfo();
$expected = array (
0 => 0,
1 => false,
2 => false,
);
$this->assertEqual($expected, $result);
}
// --------------------------------------------------------------------------
public function testErrorCode()
{
$result = self::$db->errorCode();
$this->assertEquals(00000, $result);
}
// --------------------------------------------------------------------------
public function testDBList()
{
$res = self::$db->get_sql()->db_list();
$this->assertNULL($res);
}
}