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 @@