From d4e99aa5cd4ac1c8bbf3f2fe16b6df074b16c05b Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Fri, 7 Feb 2014 16:53:01 -0500 Subject: [PATCH] Test and doc updates --- autoload.php | 4 +- classes/db_util.php | 5 +- common.php | 25 +- docs/classes/BadConnectionException.html | 2 +- docs/classes/BadDBDriverException.html | 2 +- docs/classes/DB_PDO.html | 2 +- docs/classes/DB_Util.html | 6 +- docs/classes/Firebird.html | 2 +- docs/classes/Firebird_Result.html | 14 +- docs/classes/Firebird_SQL.html | 18 +- docs/classes/Firebird_Util.html | 2 +- docs/classes/MySQL.html | 2 +- docs/classes/MySQL_SQL.html | 18 +- docs/classes/MySQL_Util.html | 2 +- docs/classes/ODBC.html | 2 +- docs/classes/ODBC_SQL.html | 18 +- docs/classes/ODBC_Util.html | 2 +- docs/classes/PgSQL.html | 2 +- docs/classes/PgSQL_SQL.html | 18 +- docs/classes/PgSQL_Util.html | 2 +- docs/classes/Query_Builder.html | 30 +- docs/classes/Query_Parser.html | 2 +- docs/classes/SQLite.html | 34 +- docs/classes/SQLite_SQL.html | 18 +- docs/classes/SQLite_Util.html | 2 +- docs/classes/iDB_SQL.html | 18 +- docs/classes/iQuery_Builder.html | 48 +- docs/deprecated.html | 2 +- docs/errors.html | 2 +- docs/graph_class.html | 2 +- docs/markers.html | 2 +- docs/namespaces/global.html | 4 +- docs/packages/Default.html | 2 +- docs/packages/Query.Drivers.html | 2 +- docs/packages/Query.Query.html | 2 +- docs/packages/Query.html | 28 +- docs/structure.xml | 2063 ++++++++++++---------- tests/core/db_test.php | 6 + tests/databases/firebird/firebird-qb.php | 44 +- tests/databases/mysql/mysql-qb.php | 2 +- tests/databases/pgsql/pgsql-qb.php | 2 +- tests/db_files/FB_TEST_DB.FDB | Bin 802816 -> 823296 bytes 42 files changed, 1370 insertions(+), 1093 deletions(-) diff --git a/autoload.php b/autoload.php index 7507aed..370f1b6 100644 --- a/autoload.php +++ b/autoload.php @@ -31,7 +31,7 @@ define('QDRIVER_PATH', QBASE_PATH.'drivers/'); require(QBASE_PATH.'common.php'); /** - * Load a Query class + * Load query classes * * @param string $class */ @@ -66,4 +66,4 @@ function query_autoload($class) // Set up autoloader spl_autoload_register('query_autoload'); -// End of autoload.php +// End of autoload.php \ No newline at end of file diff --git a/classes/db_util.php b/classes/db_util.php index c88d57a..c1ba15b 100644 --- a/classes/db_util.php +++ b/classes/db_util.php @@ -43,6 +43,7 @@ abstract class DB_Util { * * @param string $method * @param array $args + * @return mixed */ public function __call($method, $args) { @@ -50,8 +51,6 @@ abstract class DB_Util { { return call_user_func_array(array($this->conn, $method), $args); } - - return NULL; } // -------------------------------------------------------------------------- @@ -96,4 +95,4 @@ abstract class DB_Util { abstract public function backup_data(); } -// End of db_util.php +// End of db_util.php \ No newline at end of file diff --git a/common.php b/common.php index 5171dc2..2d161c2 100644 --- a/common.php +++ b/common.php @@ -59,7 +59,7 @@ if ( ! function_exists('mb_trim')) /** * Multibyte-safe trim function * - * @param string + * @param string $string * @return string */ function mb_trim($string) @@ -96,25 +96,32 @@ function db_filter($array, $index) * * @param mixed $params * @return Query_Builder + * @throws InvalidArgumentException + * @throws BadDBDriverException + * @throws BadConnectionException */ -function Query($params = '') +function &Query($params = '') { static $connections; - - // If there's existing connection(s) just return it - if ( ! empty($connections)) + + // If you are getting a previously created connection + if (is_scalar($params)) { // If the paramater is a string, use it as an array index if (is_scalar($params) && isset($connections[$params])) { return $connections[$params]; } - elseif (empty($params) && isset($connections[0])) // Otherwise, return the last one + elseif (empty($params) && ! empty($connections)) // Otherwise, return the last one { return end($connections); } + + throw new InvalidArgumentException("The specified connection does not exist"); } + // -------------------------------------------------------------------------- + // Parse argument array / object // -------------------------------------------------------------------------- // Convert array to object @@ -143,6 +150,8 @@ function Query($params = '') throw new BadDBDriverException('Database driver does not exist, or is not supported'); } + // -------------------------------------------------------------------------- + // Attempt to connect // -------------------------------------------------------------------------- // Create the dsn for the database to connect to @@ -184,6 +193,8 @@ function Query($params = '') throw new BadConnectionException('Connection failed, invalid arguments', 2); } + // -------------------------------------------------------------------------- + // Save connection // -------------------------------------------------------------------------- // Set the table prefix, if it exists @@ -209,4 +220,4 @@ function Query($params = '') return $conn; } -// End of common.php +// End of common.php \ No newline at end of file diff --git a/docs/classes/BadConnectionException.html b/docs/classes/BadConnectionException.html index ce3296a..62453a4 100644 --- a/docs/classes/BadConnectionException.html +++ b/docs/classes/BadConnectionException.html @@ -85,7 +85,7 @@ Template is built using Twitter Bootstrap 2 and icons provided by Glyphicons.
Documentation is powered by phpDocumentor 2.1.0 and
- generated on 2013-12-09T19:45:46-05:00.
+ generated on 2014-02-07T16:51:34-05:00.
diff --git a/docs/classes/BadDBDriverException.html b/docs/classes/BadDBDriverException.html index 6b51475..a735a6a 100644 --- a/docs/classes/BadDBDriverException.html +++ b/docs/classes/BadDBDriverException.html @@ -85,7 +85,7 @@ Template is built using Twitter Bootstrap 2 and icons provided by Glyphicons.
Documentation is powered by phpDocumentor 2.1.0 and
- generated on 2013-12-09T19:45:46-05:00.
+ generated on 2014-02-07T16:51:34-05:00.
diff --git a/docs/classes/DB_PDO.html b/docs/classes/DB_PDO.html index 52aed4b..4051c33 100644 --- a/docs/classes/DB_PDO.html +++ b/docs/classes/DB_PDO.html @@ -525,7 +525,7 @@ the connection/database Template is built using Twitter Bootstrap 2 and icons provided by Glyphicons.
Documentation is powered by phpDocumentor 2.1.0 and
- generated on 2013-12-09T19:45:45-05:00.
+ generated on 2014-02-07T16:51:34-05:00.
diff --git a/docs/classes/DB_Util.html b/docs/classes/DB_Util.html index 5ae2f55..cb7f423 100644 --- a/docs/classes/DB_Util.html +++ b/docs/classes/DB_Util.html @@ -100,7 +100,7 @@  Methods

Enable calling driver methods

-
__call(string $method, array $args) 
+
__call(string $method, array $args) : mixed
@@ -113,6 +113,8 @@

$args

array
+

Returns

+
mixed
@@ -222,7 +224,7 @@ Template is built using Twitter Bootstrap 2 and icons provided by Glyphicons.
Documentation is powered by phpDocumentor 2.1.0 and
- generated on 2013-12-09T19:45:45-05:00.
+ generated on 2014-02-07T16:51:34-05:00.
diff --git a/docs/classes/Firebird.html b/docs/classes/Firebird.html index 0fc3fdb..c5130dd 100644 --- a/docs/classes/Firebird.html +++ b/docs/classes/Firebird.html @@ -348,7 +348,7 @@ the last query executed Template is built using Twitter Bootstrap 2 and icons provided by Glyphicons.
Documentation is powered by phpDocumentor 2.1.0 and
- generated on 2013-12-09T19:45:45-05:00.
+ generated on 2014-02-07T16:51:34-05:00.
diff --git a/docs/classes/Firebird_Result.html b/docs/classes/Firebird_Result.html index 433c634..43647e5 100644 --- a/docs/classes/Firebird_Result.html +++ b/docs/classes/Firebird_Result.html @@ -238,7 +238,7 @@ the query

Emulate PDO fetch public function

-
fetch(int $fetch_style, mixed $statement, mixed $offset) : mixed
+
fetch(int $fetch_style, $cursor_orientation, $cursor_offset) : mixed
@@ -247,14 +247,8 @@ the query

$fetch_style

int
-
-

$statement

-mixed -
-
-

$offset

-mixed -
+

$cursor_orientation

+

$cursor_offset

Returns

mixed
@@ -360,7 +354,7 @@ the query Template is built using Twitter Bootstrap 2 and icons provided by Glyphicons.
Documentation is powered by phpDocumentor 2.1.0 and
- generated on 2013-12-09T19:45:45-05:00.
+ generated on 2014-02-07T16:51:34-05:00.
diff --git a/docs/classes/Firebird_SQL.html b/docs/classes/Firebird_SQL.html index 23252c7..27c9b3c 100644 --- a/docs/classes/Firebird_SQL.html +++ b/docs/classes/Firebird_SQL.html @@ -57,6 +57,7 @@