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.