From 49503dfb3d915f8d92da399c5071682f8337f438 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 16 Apr 2012 13:43:41 -0400 Subject: [PATCH] Start of last unimplemented methods --- classes/query_builder.php | 131 ++++++++++++++++++++++++---------- tests/db_files/FB_TEST_DB.FDB | Bin 802816 -> 802816 bytes 2 files changed, 93 insertions(+), 38 deletions(-) diff --git a/classes/query_builder.php b/classes/query_builder.php index 4cbb18a..17f8553 100644 --- a/classes/query_builder.php +++ b/classes/query_builder.php @@ -481,6 +481,34 @@ class Query_Builder { return $this; } + + // -------------------------------------------------------------------------- + + /** + * Generates a 'Having' clause + * + * @param mixed $key + * @param mixed $val + * @return $this + */ + public function having($key, $val=array()) + { + // @todo Implement having + } + + // -------------------------------------------------------------------------- + + /** + * Generates a 'Having' clause prefixed with 'OR' + * + * @param mixed $key + * @param mixed $val + * @return $this + */ + public function or_having($key, $val=array()) + { + // @todo Implement or_having + } // -------------------------------------------------------------------------- // ! 'Where' methods @@ -718,6 +746,44 @@ class Query_Builder { // -------------------------------------------------------------------------- // ! Other Query Modifier methods // -------------------------------------------------------------------------- + + /** + * Sets values for inserts / updates / deletes + * + * @param mixed $key + * @param mixed $val + * @return $this + */ + public function set($key, $val) + { + // Plain key, value pair + if (is_scalar($key) && is_scalar($val)) + { + $this->set_array[$key] = $val; + $this->values[] = $val; + } + // Object or array + elseif ( ! is_scalar($key)) + { + foreach($key as $k => $v) + { + $this->set_array[$k] = $v; + $this->values[] = $val; + } + } + + // Use the keys of the array to make the insert/update string + // Escape the field names + $this->set_array_keys = array_map(array($this->db, 'quote_ident'), array_keys($this->set_array)); + + // Generate the "set" string + $this->set_string = implode('=?, ', $this->set_array_keys); + $this->set_string .= '=?'; + + return $this; + } + + // -------------------------------------------------------------------------- /** * Creates a join phrase in a compiled query @@ -967,6 +1033,33 @@ class Query_Builder { return $this->get($table, $limit, $offset); } + // -------------------------------------------------------------------------- + + /** + * Retreive the number of rows in the selected table + * + * @param string $table + * @return int + */ + public function count_all($table) + { + //@todo Implement count_all + } + + // -------------------------------------------------------------------------- + + /** + * Retrieve the number of results for the generated query - used + * in place of the get() method + * + * @param string $table + * @return int + */ + public function count_all_results($table='') + { + // @todo Implement count_all_results + } + // -------------------------------------------------------------------------- /** @@ -1053,44 +1146,6 @@ class Query_Builder { // ! Miscellaneous Methods // -------------------------------------------------------------------------- - /** - * Sets values for inserts / updates / deletes - * - * @param mixed $key - * @param mixed $val - * @return $this - */ - public function set($key, $val) - { - // Plain key, value pair - if (is_scalar($key) && is_scalar($val)) - { - $this->set_array[$key] = $val; - $this->values[] = $val; - } - // Object or array - elseif ( ! is_scalar($key)) - { - foreach($key as $k => $v) - { - $this->set_array[$k] = $v; - $this->values[] = $val; - } - } - - // Use the keys of the array to make the insert/update string - // Escape the field names - $this->set_array_keys = array_map(array($this->db, 'quote_ident'), array_keys($this->set_array)); - - // Generate the "set" string - $this->set_string = implode('=?, ', $this->set_array_keys); - $this->set_string .= '=?'; - - return $this; - } - - // -------------------------------------------------------------------------- - /** * Calls a function further down the inheritence chain * diff --git a/tests/db_files/FB_TEST_DB.FDB b/tests/db_files/FB_TEST_DB.FDB index faf60be336bc64616eeee1f00633efee0006c91b..e4f6dfcaf6800cd83ef8c98ec1ea371d8d956c8e 100755 GIT binary patch delta 1360 zcmYjR%}*0i5TAYBw$Mq_2aSRP+uAP(CQ{-jCPrwCBt4)9!oh>0q9%p}19#JK*n=^K z#KafntTA3RYT!or5ApSE1H}2Vyij@9hrsZFVQW-Ffqy-@KVEmHJDi{t*iX z^7j*Puq2iOKGHVr0OaTf5Z3%xfYGy`y3e(H4iW@i;|5stOgkTrjlYl0N>^I06s`=o z(spIgl_6J#UD@Qy<^>tCrRa7RL&?aa@Y6vVU7YKV+-`F7k%c_k@2>v|dcpZQX2oG5 zkcHR5EDVNHFcC_^uV4>+w8`30n6pzbX{Vtxl!gl7OLh+=34acz;S1qC+N;-SAPSEI z>Q))g2z1noG8VPn&^GEQQNz4?SjW}^lG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