From f03afaa98bad60905edd03e769c4b7df7b2d9e1e Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Tue, 17 Apr 2012 16:57:28 -0400 Subject: [PATCH] Made Firebird_Result class Extend PDOStatement --- autoload.php | 2 + drivers/firebird/firebird_result.php | 9 +- tests/databases/firebird/firebird-qb.php | 277 +---------------------- tests/db_files/FB_TEST_DB.FDB | Bin 802816 -> 802816 bytes 4 files changed, 7 insertions(+), 281 deletions(-) diff --git a/autoload.php b/autoload.php index 9bd0d64..2e9c1e0 100644 --- a/autoload.php +++ b/autoload.php @@ -48,6 +48,8 @@ if (function_exists('fbird_connect')) array_map('do_include', glob(DRIVER_PATH.'/firebird/*.php')); } +// -------------------------------------------------------------------------- + /** * Filter out db rows into one array * diff --git a/drivers/firebird/firebird_result.php b/drivers/firebird/firebird_result.php index d28f99b..c209bd6 100644 --- a/drivers/firebird/firebird_result.php +++ b/drivers/firebird/firebird_result.php @@ -16,9 +16,8 @@ * Firebird result class to emulate PDOStatement Class - only implements * data-fetching methods * - * @todo Implement more of the PDOStatement Class */ -class Firebird_Result { +class Firebird_Result extends PDOStatement { private $statement; @@ -41,7 +40,7 @@ class Firebird_Result { * @param int $fetch_style * @return mixed */ - public function fetch($fetch_style=PDO::FETCH_ASSOC, $statement=NULL) + public function fetch($fetch_style=PDO::FETCH_ASSOC, $statement=NULL, $offset=NULL) { if ( ! is_null($statement)) { @@ -72,7 +71,7 @@ class Firebird_Result { * @param int $fetch_style * @return mixed */ - public function fetchAll($fetch_style=PDO::FETCH_ASSOC, $statement=NULL) + public function fetchAll($fetch_style=PDO::FETCH_ASSOC, $statement=NULL, $ctor_args=NULL) { $all = array(); @@ -108,7 +107,7 @@ class Firebird_Result { * @param array $args * @return bool */ - public function execute($args) + public function execute($args = NULL) { //Add the prepared statement as the first parameter array_unshift($args, $this->statement); diff --git a/tests/databases/firebird/firebird-qb.php b/tests/databases/firebird/firebird-qb.php index 96ec990..a4cc331 100644 --- a/tests/databases/firebird/firebird-qb.php +++ b/tests/databases/firebird/firebird-qb.php @@ -33,280 +33,5 @@ class FirebirdQBTest extends QBTest { $this->db = new Query_Builder($params); // echo '
Firebird Queries
'; - } - - function TestGet() - { - $query = $this->db->get('create_test ct'); - - $this->assertIsA($query, 'Firebird_Result'); - } - - function TestGetLimit() - { - $query = $this->db->get('create_test', 2); - - $this->assertIsA($query, 'Firebird_Result'); - } - - function TestGetLimitSkip() - { - $query = $this->db->get('create_test', 2, 1); - - $this->assertIsA($query, 'Firebird_Result'); - } - - function TestHaving() - { - if (empty($this->db)) return; - - $query = $this->db->select('id') - ->from('create_test') - ->group_by('id') - ->having(array('id >' => 1)) - ->having('id !=', 3) - ->get(); - - $this->assertIsA($query, 'Firebird_Result'); - } - - function TestOrHaving() - { - if (empty($this->db)) return; - - $query = $this->db->select('id') - ->from('create_test') - ->group_by('id') - ->having(array('id >' => 1)) - ->or_having('id !=', 3) - ->get(); - - $this->assertIsA($query, 'Firebird_Result'); - } - - function TestSelectWhereGet() - { - $query = $this->db->select('id, key as k, val') - ->where('id >', 1) - ->where('id <', 800) - ->get('create_test', 2, 1); - - $this->assertIsA($query, 'Firebird_Result'); - } - - function TestSelectWhereGet2() - { - $query = $this->db->select('id, key as k, val') - ->where(' id ', 1) - - ->get('create_test', 2, 1); - - $this->assertIsA($query, 'Firebird_Result'); - } - - function TestSelectMax() - { - if (empty($this->db)) return; - - $query = $this->db->select_max('id', 'di') - ->get('create_test'); - - $this->assertIsA($query, 'Firebird_Result'); - } - - function TestSelectMin() - { - if (empty($this->db)) return; - - $query = $this->db->select_min('id', 'di') - ->get('create_test'); - - $this->assertIsA($query, 'Firebird_Result'); - } - - function TestSelectAvg() - { - if (empty($this->db)) return; - - $query = $this->db->select_avg('id', 'di') - ->get('create_test'); - - $this->assertIsA($query, 'Firebird_Result'); - } - - function TestSelectSum() - { - if (empty($this->db)) return; - - $query = $this->db->select_sum('id', 'di') - ->get('create_test'); - - $this->assertIsA($query, 'Firebird_Result'); - } - - function TestSelectDistinct() - { - if (empty($this->db)) return; - - $query = $this->db->select_sum('id', 'di') - ->distinct() - ->get('create_test'); - - $this->assertIsA($query, 'Firebird_Result'); - } - - function TestGetWhere() - { - if (empty($this->db)) return; - - $query = $this->db->get_where('create_test', array('id !=' => 1), 2, 1); - - $this->assertIsA($query, 'Firebird_Result'); - } - - function TestSelectGet() - { - $query = $this->db->select('id, key as k, val') - ->get('create_test', 2, 1); - - $this->assertIsA($query, 'Firebird_Result'); - } - - function TestSelectFromGet() - { - $query = $this->db->select('id, key as k, val') - ->from('create_test ct') - ->where('id >', 1) - ->get(); - - $this->assertIsA($query, 'Firebird_Result'); - } - - function TestSelectFromLimitGet() - { - $query = $this->db->select('id, key as k, val') - ->from('create_test ct') - ->where('id >', 1) - ->limit(3) - ->get(); - - $this->assertIsA($query, 'Firebird_Result'); - } - - function TestOrderBy() - { - $query = $this->db->select('id, key as k, val') - ->from('create_test') - ->where('id >', 0) - ->where('id <', 9000) - ->order_by('id', 'DESC') - ->order_by('k', 'ASC') - ->limit(5,2) - ->get(); - - $this->assertIsA($query, 'Firebird_Result'); - } - - function TestOrderByRandom() - { - $query = $this->db->select('id, key as k, val') - ->from('create_test') - ->where('id >', 0) - ->where('id <', 9000) - ->order_by('id', 'rand') - ->limit(5,2) - ->get(); - - $this->assertIsA($query, 'Firebird_Result'); - } - - function TestOrWhere() - { - $query = $this->db->select('id, key as k, val') - ->from('create_test') - ->where(' id ', 1) - ->or_where('key >', 0) - ->limit(2, 1) - ->get(); - - $this->assertIsA($query, 'Firebird_Result'); - } - - function TestGroupBy() - { - - } - - /*function TestGroupBy() - { - $query = $this->db->select('id, key as k, val') - ->from('create_test') - ->where('id >', 0) - ->where('id <', 9000) - ->group_by('k') - ->group_by('val') - ->order_by('id', 'DESC') - ->order_by('k', 'ASC') - ->limit(5,2) - ->get(); - - $this->assertIsA($query, 'Firebird_Result'); - }*/ - - function TestLike() - { - $query = $this->db->from('create_test') - ->like('key', 'og') - ->get(); - - $this->assertIsA($query, 'Firebird_Result'); - } - - function TestWhereIn() - { - $query = $this->db->from('create_test') - ->where_in('key', array(12, 96, "works")) - ->get(); - - $this->assertIsA($query, 'Firebird_Result'); - } - - function TestJoin() - { - $query = $this->db->from('create_test') - ->join('create_join cj', 'cj.id = create_test.id') - ->get(); - - $this->assertIsA($query, 'Firebird_Result'); - } - - function TestInsert() - { - $query = $this->db->set('id', 4) - ->set('key', 4) - ->set('val', 5) - ->insert('create_test'); - - $this->assertTrue($query); - } - - function TestUpdate() - { - $query = $this->db->set('id', 4) - ->set('key', 'gogle') - ->set('val', 'non-word') - ->where('id', 4) - ->update('create_test'); - - $this->assertTrue($query); - } - - function TestDelete() - { - $query = $this->db->where('id', 4)->delete('create_test'); - - $this->assertTrue($query); - } - - + } } \ No newline at end of file diff --git a/tests/db_files/FB_TEST_DB.FDB b/tests/db_files/FB_TEST_DB.FDB index 0252e62c4e5c15e0bda44e2673b41623c91bf5f4..c75f825bbc0d786f4a863f4c83f74b411ea2825b 100644 GIT binary patch delta 1953 zcmb7_O-NKx6vxkd<9s-$=eug6W%@>KRElB-Myf^jv8c!r7vWMAT8aZ^v?_;?w~7c_ z+(i(yi54x)LU%%&AU8@&2|~xwM6wTB2!l-L-Zy8Sjw1Pn`|kVS&)>P{+%uU>GLuR6 z8gL;o5Ci`ams_Pwq<5U1lZE1 zjarzn;_%gOg%5Tdp4go*Y{%dhl}>7Fur2so)dmYx-c)tM1l40z7W7fwSrvx{`c}`F zWx-pkotM@1>@EdhfRNv^c=U)iyVxn`f8co>4#Lpzz4RsOkylsnrg_YfPgk%>;&-f- zvnyy_PnnQRsq<3HnzWeF?46&|fig|Ky1%wKUTv<%*E+H$hw;-TvIq$MtqwRsh3a$! zM$#i^9;8R_>IqX>yb@3|o0qUne$HXDk4vp1Kk=;0tm6r@&XF(IF|h-ew`W||6(tP!c$T$A`gw+E47{=B%1l3llj}Yu9XV`K+i?Q&ivWJ!?7sTYJ9JcuOP^-45Zk6n@ z9NE3P%O2+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