diff --git a/classes/db_pdo.php b/classes/db_pdo.php index 43da9dc..e2d7bea 100644 --- a/classes/db_pdo.php +++ b/classes/db_pdo.php @@ -522,13 +522,5 @@ abstract class DB_PDO extends PDO { * @return void */ abstract public function truncate($table); - - /** - * Connect to a different database - * - * @param string $name - * @return void - */ - abstract public function switch_db($name); } // End of db_pdo.php \ No newline at end of file diff --git a/classes/db_util.php b/classes/db_util.php index 7102d5b..da9ffac 100644 --- a/classes/db_util.php +++ b/classes/db_util.php @@ -95,4 +95,5 @@ abstract class DB_Util { */ abstract public function backup_data(); -} \ No newline at end of file +} +// End of db_util.php \ No newline at end of file diff --git a/classes/db_sql.php b/classes/idb_sql.php similarity index 70% rename from classes/db_sql.php rename to classes/idb_sql.php index b41e046..b1e373a 100644 --- a/classes/db_sql.php +++ b/classes/idb_sql.php @@ -14,12 +14,12 @@ // -------------------------------------------------------------------------- /** - * Abstract parent for database manipulation subclasses + * parent for database manipulation subclasses * * @package Query * @subpackage Query */ -abstract class DB_SQL { +interface iDB_SQL { /** * Get database specific sql for limit clause @@ -30,7 +30,7 @@ abstract class DB_SQL { * @param int $offset * @return string */ - abstract public function limit($sql, $limit, $offset=FALSE); + public function limit($sql, $limit, $offset=FALSE); /** * Get the sql for random ordering @@ -38,70 +38,70 @@ abstract class DB_SQL { * @abstract * @return string */ - abstract public function random(); + public function random(); /** * Returns sql to list other databases * * @return string */ - abstract public function db_list(); + public function db_list(); /** * Returns sql to list tables * * @return string */ - abstract public function table_list(); + public function table_list(); /** * Returns sql to list system tables * * @return string */ - abstract public function system_table_list(); + public function system_table_list(); /** * Returns sql to list views * * @return string */ - abstract public function view_list(); + public function view_list(); /** * Returns sql to list triggers * * @return string */ - abstract public function trigger_list(); + public function trigger_list(); /** * Return sql to list functions * * @return FALSE */ - abstract public function function_list(); + public function function_list(); /** * Return sql to list stored procedures * * @return string */ - abstract public function procedure_list(); + public function procedure_list(); /** * Return sql to list sequences * * @return string */ - abstract public function sequence_list(); + public function sequence_list(); /** * Return sql to list database field types * * @return mixed */ - abstract public function type_list(); + public function type_list(); /** * Get information about the columns in the @@ -110,6 +110,6 @@ abstract class DB_SQL { * @param string * @return string */ - abstract public function column_list($table); + public function column_list($table); } // End of db_sql.php \ No newline at end of file diff --git a/classes/iquery_builder.php b/classes/iquery_builder.php new file mode 100644 index 0000000..8af659a --- /dev/null +++ b/classes/iquery_builder.php @@ -0,0 +1,480 @@ +db->sql public $sql; @@ -82,10 +82,10 @@ class Query_Builder { // 'conjunction' => ' AND ', // 'string' => 'k=?' // ) - private $query_map; + protected $query_map; // Map for having clause - private $having_map; + protected $having_map; // Convenience property for connection management public $conn_name = ""; @@ -103,7 +103,7 @@ class Query_Builder { * @param DB_PDO $db * @param object $params - the connection parameters */ - public function __construct(&$db, &$params) + public function __construct(&$db, $params) { $this->db = $db; @@ -176,7 +176,7 @@ class Query_Builder { * @param string $as * @return string */ - private function _select($field, $as = FALSE) + protected function _select($field, $as = FALSE) { // Escape the identifiers $field = $this->db->quote_ident($field); @@ -304,7 +304,7 @@ class Query_Builder { * @param string $conj * @return $this */ - private function _like($field, $val, $pos, $like='LIKE', $conj='AND') + protected function _like($field, $val, $pos, $like='LIKE', $conj='AND') { $field = $this->db->quote_ident($field); @@ -408,7 +408,7 @@ class Query_Builder { * @param string $conj * @return $this */ - private function _having($key, $val=array(), $conj='AND') + protected function _having($key, $val=array(), $conj='AND') { $where = $this->_where($key, $val); @@ -473,7 +473,7 @@ class Query_Builder { * @param mixed $val * @return array */ - private function _where($key, $val=array()) + protected function _where($key, $val=array()) { $where = array(); @@ -506,7 +506,7 @@ class Query_Builder { * @param string $conj * @return $this */ - private function _where_string($key, $val=array(), $conj='AND') + protected function _where_string($key, $val=array(), $conj='AND') { $where = $this->_where($key, $val); @@ -544,7 +544,7 @@ class Query_Builder { * @param string * @return $this */ - private function _where_in($key, $val=array(), $in='IN', $conj='AND') + protected function _where_in($key, $val=array(), $in='IN', $conj='AND') { $key = $this->db->quote_ident($key); $params = array_fill(0, count($val), '?'); @@ -1056,7 +1056,7 @@ class Query_Builder { } // -------------------------------------------------------------------------- - // ! Query Returning Methods + // ! SQL Returning Methods // -------------------------------------------------------------------------- /** @@ -1094,7 +1094,7 @@ class Query_Builder { // -------------------------------------------------------------------------- /** - * Returns the generated 'insert' sql query + * Returns the generated 'update' sql query * * @param string $table * @param bool $reset @@ -1108,7 +1108,7 @@ class Query_Builder { // -------------------------------------------------------------------------- /** - * Returns the generated 'insert' sql query + * Returns the generated 'delete' sql query * * @param string $table * @param bool $reset @@ -1129,7 +1129,7 @@ class Query_Builder { * @param bool * @resturn string */ - private function _get_compile($type, $table, $reset) + protected function _get_compile($type, $table, $reset) { $sql = $this->_compile($type, $table); @@ -1185,7 +1185,7 @@ class Query_Builder { * @param bool $simple * @return mixed */ - private function _run($type, $table, $simple=FALSE) + protected function _run($type, $table, $simple=FALSE) { $sql = $this->_compile($type, $table); $vals = array_merge($this->values, (array) $this->where_values); @@ -1227,7 +1227,7 @@ class Query_Builder { * @param string $table * @return $string */ - private function _compile($type='', $table='') + protected function _compile($type='', $table='') { $sql = ''; diff --git a/common.php b/common.php index 73f6baa..7709a76 100644 --- a/common.php +++ b/common.php @@ -192,7 +192,7 @@ function Query($params = '') $db->table_prefix = $params->prefix; } - // Create the database connection + // Create the Query Builder object $conn = new Query_Builder($db, $params); // Save it for later diff --git a/docs/classes.svg b/docs/classes.svg index 924d2de..c6e864a 100644 --- a/docs/classes.svg +++ b/docs/classes.svg @@ -10,14 +10,14 @@