diff --git a/index.php b/index.php index 1cfc5a8..edc1fe6 100644 --- a/index.php +++ b/index.php @@ -79,6 +79,7 @@ function do_include($path) // Load everything so that we don't have to do requires later { array_map('do_include', glob(BASE_DIR . "/common/*.php")); + array_map('do_include', glob(BASE_DIR . "/db/*.php")); array_map('do_include', glob(BASE_DIR . "/windows/widgets/*.php")); array_map('do_include', glob(BASE_DIR . "/windows/*.php")); } @@ -86,7 +87,7 @@ function do_include($path) // -------------------------------------------------------------------------- // Load db classes based on capability -$path = BASE_DIR . "/databases/"; +$path = BASE_DIR . "/db/drivers/"; foreach(pdo_drivers() as $d) { diff --git a/sys/common/db_pdo.php b/sys/db/db_pdo.php similarity index 99% rename from sys/common/db_pdo.php rename to sys/db/db_pdo.php index 011b7b3..dcd0e11 100644 --- a/sys/common/db_pdo.php +++ b/sys/db/db_pdo.php @@ -22,6 +22,9 @@ abstract class DB_PDO extends PDO { public $manip; protected $statement; + /** + * PDO constructor wrapper + */ public function __construct($dsn, $username=NULL, $password=NULL, $driver_options=array()) { parent::__construct($dsn, $username, $password, $driver_options); diff --git a/sys/databases/firebird-ibase.php b/sys/db/drivers/firebird-ibase.php similarity index 99% rename from sys/databases/firebird-ibase.php rename to sys/db/drivers/firebird-ibase.php index cbd5135..eec03b6 100644 --- a/sys/databases/firebird-ibase.php +++ b/sys/db/drivers/firebird-ibase.php @@ -95,11 +95,9 @@ class firebird extends DB_PDO { } // Throw the error as a exception - // if there is one if ($this->statement === FALSE) { throw new PDOException(ibase_errmsg()); - die(); } return $this->statement; @@ -169,7 +167,6 @@ class firebird extends DB_PDO { if ($this->statement === FALSE) { throw new PDOException(ibase_errmsg()); - die(); } return $this->statement; diff --git a/sys/databases/firebird_sql.php b/sys/db/drivers/firebird_sql.php similarity index 100% rename from sys/databases/firebird_sql.php rename to sys/db/drivers/firebird_sql.php diff --git a/sys/databases/mysql.php b/sys/db/drivers/mysql.php similarity index 100% rename from sys/databases/mysql.php rename to sys/db/drivers/mysql.php diff --git a/sys/databases/mysql_sql.php b/sys/db/drivers/mysql_sql.php similarity index 100% rename from sys/databases/mysql_sql.php rename to sys/db/drivers/mysql_sql.php diff --git a/sys/databases/odbc.php b/sys/db/drivers/odbc.php similarity index 100% rename from sys/databases/odbc.php rename to sys/db/drivers/odbc.php diff --git a/sys/databases/odbc_sql.php b/sys/db/drivers/odbc_sql.php similarity index 100% rename from sys/databases/odbc_sql.php rename to sys/db/drivers/odbc_sql.php diff --git a/sys/databases/pgsql.php b/sys/db/drivers/pgsql.php similarity index 100% rename from sys/databases/pgsql.php rename to sys/db/drivers/pgsql.php diff --git a/sys/databases/pgsql_sql.php b/sys/db/drivers/pgsql_sql.php similarity index 100% rename from sys/databases/pgsql_sql.php rename to sys/db/drivers/pgsql_sql.php diff --git a/sys/databases/sqlite.php b/sys/db/drivers/sqlite.php similarity index 100% rename from sys/databases/sqlite.php rename to sys/db/drivers/sqlite.php diff --git a/sys/databases/sqlite_sql.php b/sys/db/drivers/sqlite_sql.php similarity index 100% rename from sys/databases/sqlite_sql.php rename to sys/db/drivers/sqlite_sql.php diff --git a/sys/common/query_builder.php b/sys/db/query_builder.php similarity index 68% rename from sys/common/query_builder.php rename to sys/db/query_builder.php index be95e2b..fe0f8b9 100644 --- a/sys/common/query_builder.php +++ b/sys/db/query_builder.php @@ -127,4 +127,65 @@ class Query_Builder { return $this->query('SELECT * FROM ' . $this->quote_ident($table)); } } + + // -------------------------------------------------------------------------- + + /** + * Specifies rows to select in a query + * + * @param string $fields + * @return $this + */ + public function select($fields) + { + // @todo Implement select method + return $this; + } + + // -------------------------------------------------------------------------- + + /** + * Specify condition(s) in the where clause of a query + * Note: this function works with key / value, or a + * passed array with key / value pairs + * + * @param mixed $key + * @param mixed $val + * @return $this + */ + public function where($key, $val=array()) + { + // @todo Implement where method + return $this; + } + + // -------------------------------------------------------------------------- + + /** + * Creates a join phrase in a compiled query + * + * @param string $table + * @param string $condition + * @param string $type + * @return $this + */ + public function join($table, $condition, $type='inner') + { + // @todo Implement join method + return $this; + } + + // -------------------------------------------------------------------------- + + /** + * Specify the database table to select from + * + * @param string $dbname + * @return $this + */ + public function from($dbname) + { + // @todo Implement from method + return $this; + } } \ No newline at end of file diff --git a/tests/index.php b/tests/index.php index 40f3e6d..f8846c4 100644 --- a/tests/index.php +++ b/tests/index.php @@ -32,13 +32,13 @@ function do_include($path) // Include core tests require_once("core.php"); -require_once("../sys/common/db_pdo.php"); -require_once("../sys/common/query_builder.php"); +require_once("../sys/db/db_pdo.php"); +require_once("../sys/db/query_builder.php"); // Include db tests // Load db classes based on capability -$src_path = "../sys/databases/"; +$src_path = "../sys/db/drivers/"; $test_path = "./databases/"; foreach(pdo_drivers() as $d) diff --git a/tests/test_dbs/FB_TEST_DB.FDB b/tests/test_dbs/FB_TEST_DB.FDB index b79c428..90a4ba4 100755 Binary files a/tests/test_dbs/FB_TEST_DB.FDB and b/tests/test_dbs/FB_TEST_DB.FDB differ