From dc0a8b7bc14c4cde6de144a28721df2a6a8ebf8f Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 30 Apr 2012 16:06:06 -0400 Subject: [PATCH] More method simplification --- autoload.php | 10 +- classes/query_builder.php | 178 +++---- docs/classes/DB_PDO.html | 2 +- docs/classes/DB_Reg.html | 2 +- docs/classes/DB_SQL.html | 2 +- docs/classes/DB_Util.html | 2 +- docs/classes/Firebird.html | 2 +- docs/classes/Firebird_Result.html | 2 +- docs/classes/Firebird_SQL.html | 2 +- docs/classes/Firebird_Util.html | 2 +- docs/classes/MySQL.html | 2 +- docs/classes/MySQL_SQL.html | 2 +- docs/classes/MySQL_Util.html | 2 +- docs/classes/ODBC.html | 2 +- docs/classes/ODBC_SQL.html | 2 +- docs/classes/ODBC_Util.html | 2 +- docs/classes/PgSQL.html | 2 +- docs/classes/PgSQL_SQL.html | 2 +- docs/classes/PgSQL_Util.html | 2 +- docs/classes/Query_Builder.html | 56 ++- docs/classes/SQLite.html | 2 +- docs/classes/SQLite_SQL.html | 2 +- docs/classes/SQLite_Util.html | 2 +- docs/classes/Settings.html | 2 +- docs/deprecated.html | 2 +- docs/errors.html | 2 +- docs/graph_class.html | 2 +- docs/markers.html | 2 +- docs/namespaces/default.html | 10 +- docs/packages/.html | 2 +- docs/packages/Default.html | 14 +- docs/packages/Query.Drivers.html | 2 +- docs/packages/Query.Helper Classes.html | 2 +- docs/packages/Query.Query.html | 2 +- docs/packages/Query.html | 2 +- docs/structure.xml | 597 +++++++++++++---------- tests/TEST_DIRDSdb_filesDStest_sqlite.db | Bin 0 -> 3072 bytes tests/databases/firebird/firebird-qb.php | 2 +- tests/databases/firebird/firebird.php | 2 +- tests/databases/mysql/mysql-qb.php | 4 +- tests/databases/mysql/mysql.php | 4 +- tests/databases/pgsql/pgsql-qb.php | 4 +- tests/databases/pgsql/pgsql.php | 4 +- tests/databases/sqlite/sqlite-qb.php | 2 +- tests/databases/sqlite/sqlite.php | 2 +- tests/db_files/FB_TEST_DB.FDB | Bin 802816 -> 802816 bytes tests/index.php | 20 +- 47 files changed, 526 insertions(+), 443 deletions(-) create mode 100644 tests/TEST_DIRDSdb_filesDStest_sqlite.db diff --git a/autoload.php b/autoload.php index 6d252cd..e95de2c 100644 --- a/autoload.php +++ b/autoload.php @@ -20,12 +20,12 @@ /** * Reference to root path */ -define('BASE_PATH', dirname(__FILE__).'/'); +define('QBASE_PATH', dirname(__FILE__).'/'); /** * Path to driver classes */ -define('DRIVER_PATH', BASE_PATH.'drivers/'); +define('QDRIVER_PATH', QBASE_PATH.'drivers/'); if ( ! function_exists('do_include')) { @@ -43,12 +43,12 @@ if ( ! function_exists('do_include')) } // Load base classes -array_map('do_include', glob(BASE_PATH.'classes/*.php')); +array_map('do_include', glob(QBASE_PATH.'classes/*.php')); // Load PDO Drivers foreach(pdo_drivers() as $d) { - $dir = DRIVER_PATH.$d; + $dir = QDRIVER_PATH.$d; if(is_dir($dir)) { @@ -59,7 +59,7 @@ foreach(pdo_drivers() as $d) // Load Firebird driver, if applicable if (function_exists('fbird_connect')) { - array_map('do_include', glob(DRIVER_PATH.'/firebird/*.php')); + array_map('do_include', glob(QDRIVER_PATH.'/firebird/*.php')); } // -------------------------------------------------------------------------- diff --git a/classes/query_builder.php b/classes/query_builder.php index 1ea6534..5c14f05 100644 --- a/classes/query_builder.php +++ b/classes/query_builder.php @@ -395,21 +395,22 @@ class Query_Builder { // -------------------------------------------------------------------------- // ! 'Like' methods // -------------------------------------------------------------------------- - + /** - * Creates a Like clause in the sql statement + * Simplify 'like' methods * * @param string $field * @param mixed $val * @param string $pos - * @return $this + * @param string $like + * @param string $conj */ - public function like($field, $val, $pos='both') + private function _like($field, $val, $pos, $like='LIKE', $conj='AND') { $field = $this->quote_ident($field); // Add the like string into the order map - $l = $field. ' LIKE ?'; + $l = $field. " {$like} ?"; if ($pos == 'before') { @@ -423,16 +424,30 @@ class Query_Builder { { $val = "%{$val}%"; } - + $this->query_map[] = array( 'type' => 'like', - 'conjunction' => (empty($this->query_map)) ? 'WHERE ' : ' AND ', + 'conjunction' => (empty($this->query_map)) ? 'WHERE ' : " {$conj} ", 'string' => $l ); - + // Add to the values array $this->values[] = $val; + } + + // -------------------------------------------------------------------------- + /** + * Creates a Like clause in the sql statement + * + * @param string $field + * @param mixed $val + * @param string $pos + * @return $this + */ + public function like($field, $val, $pos='both') + { + $this->_like($field, $val, $pos); return $this; } @@ -448,21 +463,7 @@ class Query_Builder { */ public function or_like($field, $val, $pos='both') { - // Do the like method - $this->like($field, $val, $pos); - - $l = $field. ' LIKE ?'; - - // Pop the incorrect query mapping off of the array - array_pop($this->query_map); - - // Add the like string into the order map - $this->query_map[] = array( - 'type' => 'like', - 'conjunction' => (empty($this->query_map)) ? 'WHERE ' : ' OR ', - 'string' => $l - ); - + $this->_like($field, $val, $pos, 'LIKE', 'OR'); return $this; } @@ -478,21 +479,7 @@ class Query_Builder { */ public function not_like($field, $val, $pos='both') { - // Do the like method - $this->like($field, $val, $pos); - - // Pop the incorrect query mapping off of the array - array_pop($this->query_map); - - // Add the like string into the order map - $l = $field. ' NOT LIKE ?'; - - $this->query_map[] = array( - 'type' => 'like', - 'conjunction' => (empty($this->query_map)) ? ' WHERE ' : ' AND ', - 'string' => $l - ); - + $this->_like($field, $val, $pos, 'NOT LIKE'); return $this; } @@ -508,21 +495,7 @@ class Query_Builder { */ public function or_not_like($field, $val, $pos='both') { - // Do the like method - $this->like($field, $val, $pos); - - // Pop the incorrect query mapping off of the array - array_pop($this->query_map); - - // Add the like string into the order map - $l = $field. ' NOT LIKE ?'; - - $this->query_map[] = array( - 'type' => 'like', - 'conjunction' => (empty($this->query_map)) ? ' WHERE ' : ' OR ', - 'string' => $l - ); - + $this->_like($field, $val, $pos, 'NOT LIKE', 'OR'); return $this; } @@ -629,6 +602,36 @@ class Query_Builder { return $where; } + + // -------------------------------------------------------------------------- + + /** + * Simplify where_in methods + * + * @param mixed $key + * @param mixed $val + * @param string + * @param string + * @return void + */ + private function _where_in($key, $val=array(), $in='IN', $conj='AND') + { + $field = $this->quote_ident($field); + $params = array_fill(0, count($val), '?'); + + foreach($val as $v) + { + $this->values[] = $v; + } + + $string = $field . " {$in} ".implode(',', $params).') '; + + $this->query_map[] = array( + 'type' => 'where_in', + 'conjunction' => ( ! empty($this->query_map)) ? " {$conj} " : ' WHERE ', + 'string' => $string + ); + } // -------------------------------------------------------------------------- @@ -720,22 +723,7 @@ class Query_Builder { */ public function where_in($field, $val=array()) { - $field = $this->quote_ident($field); - $params = array_fill(0, count($val), '?'); - - foreach($val as $v) - { - $this->values[] = $v; - } - - $string = $field . ' IN ('.implode(',', $params).') '; - - $this->query_map[] = array( - 'type' => 'where_in', - 'conjunction' => ( ! empty($this->query_map)) ? ' AND ' : ' WHERE ', - 'string' => $string - ); - + $this->_where_in($field, $val); return $this; } @@ -750,23 +738,7 @@ class Query_Builder { */ public function or_where_in($field, $val=array()) { - // Do the were_in method - $this->where_in($field, $val); - - // Pop the incorrect query mapping off of the array - array_pop($this->query_map); - - $field = $this->quote_ident($field); - $params = array_fill(0, count($val), '?'); - - $string = $field . ' IN ('.implode(',', $params).') '; - - $this->query_map[] = array( - 'type' => 'where_in', - 'conjunction' => ( ! empty($this->query_map)) ? ' OR ' : ' WHERE ', - 'string' => $string - ); - + $this->_where_in($field, $val, 'IN', 'OR'); return $this; } @@ -781,22 +753,7 @@ class Query_Builder { */ public function where_not_in($field, $val=array()) { - $field = $this->quote_ident($field); - $params = array_fill(0, count($val), '?'); - - foreach($val as $v) - { - $this->values[] = $v; - } - - $string = $field.' NOT IN ('.implode(',', $params).') '; - - $this->query_map[] = array( - 'type' => 'where_in', - 'conjunction' => ( ! empty($this->query_map)) ? ' AND ' : ' WHERE ', - 'string' => $string - ); - + $this->_where_in($field, $val, 'NOT IN', 'AND'); return $this; } @@ -811,22 +768,7 @@ class Query_Builder { */ public function or_where_not_in($field, $val=array()) { - $field = $this->quote_ident($field); - $params = array_fill(0, count($val), '?'); - - foreach($val as $v) - { - $this->values[] = $v; - } - - $string = $field.' NOT IN ('.implode(',', $params).') '; - - $this->query_map[] = array( - 'type' => 'where_in', - 'conjunction' => ( ! empty($this->query_map)) ? ' OR ' : ' WHERE ', - 'string' => $string - ); - + $this->_where_in($field, $val, 'NOT IN', 'OR'); return $this; } diff --git a/docs/classes/DB_PDO.html b/docs/classes/DB_PDO.html index 2ff2dde..d4370f2 100644 --- a/docs/classes/DB_PDO.html +++ b/docs/classes/DB_PDO.html @@ -662,7 +662,7 @@ the connection/database
+ generated on 2012-04-30T16:05:55-04:00.
diff --git a/docs/classes/DB_Reg.html b/docs/classes/DB_Reg.html index 0b01bb4..459a46a 100644 --- a/docs/classes/DB_Reg.html +++ b/docs/classes/DB_Reg.html @@ -151,7 +151,7 @@ and organizes database connections

+ generated on 2012-04-30T16:05:55-04:00.
diff --git a/docs/classes/DB_SQL.html b/docs/classes/DB_SQL.html index 490968b..c78fe7d 100644 --- a/docs/classes/DB_SQL.html +++ b/docs/classes/DB_SQL.html @@ -268,7 +268,7 @@
+ generated on 2012-04-30T16:05:55-04:00.
diff --git a/docs/classes/DB_Util.html b/docs/classes/DB_Util.html index e5d70c7..eab5393 100644 --- a/docs/classes/DB_Util.html +++ b/docs/classes/DB_Util.html @@ -208,7 +208,7 @@
+ generated on 2012-04-30T16:05:55-04:00.
diff --git a/docs/classes/Firebird.html b/docs/classes/Firebird.html index 3de3c56..24511bf 100644 --- a/docs/classes/Firebird.html +++ b/docs/classes/Firebird.html @@ -812,7 +812,7 @@ the last query executed
+ generated on 2012-04-30T16:05:55-04:00.
diff --git a/docs/classes/Firebird_Result.html b/docs/classes/Firebird_Result.html index 990238b..87e6d7e 100644 --- a/docs/classes/Firebird_Result.html +++ b/docs/classes/Firebird_Result.html @@ -503,7 +503,7 @@ the query
+ generated on 2012-04-30T16:05:55-04:00.
diff --git a/docs/classes/Firebird_SQL.html b/docs/classes/Firebird_SQL.html index 128ef87..81fd6b2 100644 --- a/docs/classes/Firebird_SQL.html +++ b/docs/classes/Firebird_SQL.html @@ -296,7 +296,7 @@
+ generated on 2012-04-30T16:05:55-04:00.
diff --git a/docs/classes/Firebird_Util.html b/docs/classes/Firebird_Util.html index e30c95b..22845a1 100644 --- a/docs/classes/Firebird_Util.html +++ b/docs/classes/Firebird_Util.html @@ -211,7 +211,7 @@
+ generated on 2012-04-30T16:05:55-04:00.
diff --git a/docs/classes/MySQL.html b/docs/classes/MySQL.html index 3a04d8a..22a5da0 100644 --- a/docs/classes/MySQL.html +++ b/docs/classes/MySQL.html @@ -848,7 +848,7 @@ the connection/database
+ generated on 2012-04-30T16:05:55-04:00.
diff --git a/docs/classes/MySQL_SQL.html b/docs/classes/MySQL_SQL.html index b9f6c84..e6b5e49 100644 --- a/docs/classes/MySQL_SQL.html +++ b/docs/classes/MySQL_SQL.html @@ -280,7 +280,7 @@
+ generated on 2012-04-30T16:05:55-04:00.
diff --git a/docs/classes/MySQL_Util.html b/docs/classes/MySQL_Util.html index 2a07160..d0270fb 100644 --- a/docs/classes/MySQL_Util.html +++ b/docs/classes/MySQL_Util.html @@ -207,7 +207,7 @@
+ generated on 2012-04-30T16:05:55-04:00.
diff --git a/docs/classes/ODBC.html b/docs/classes/ODBC.html index 7a29de0..99f33c8 100644 --- a/docs/classes/ODBC.html +++ b/docs/classes/ODBC.html @@ -850,7 +850,7 @@ the connection/database
+ generated on 2012-04-30T16:05:55-04:00.
diff --git a/docs/classes/ODBC_SQL.html b/docs/classes/ODBC_SQL.html index 85d526d..c2bfb9e 100644 --- a/docs/classes/ODBC_SQL.html +++ b/docs/classes/ODBC_SQL.html @@ -280,7 +280,7 @@
+ generated on 2012-04-30T16:05:55-04:00.
diff --git a/docs/classes/ODBC_Util.html b/docs/classes/ODBC_Util.html index 10e6a26..51e3ebd 100644 --- a/docs/classes/ODBC_Util.html +++ b/docs/classes/ODBC_Util.html @@ -202,7 +202,7 @@
+ generated on 2012-04-30T16:05:55-04:00.
diff --git a/docs/classes/PgSQL.html b/docs/classes/PgSQL.html index 3a92011..a7e4e3a 100644 --- a/docs/classes/PgSQL.html +++ b/docs/classes/PgSQL.html @@ -850,7 +850,7 @@ the connection/database
+ generated on 2012-04-30T16:05:55-04:00.
diff --git a/docs/classes/PgSQL_SQL.html b/docs/classes/PgSQL_SQL.html index 3426273..4ded16b 100644 --- a/docs/classes/PgSQL_SQL.html +++ b/docs/classes/PgSQL_SQL.html @@ -296,7 +296,7 @@
+ generated on 2012-04-30T16:05:55-04:00.
diff --git a/docs/classes/PgSQL_Util.html b/docs/classes/PgSQL_Util.html index 584ece8..ee2a6c6 100644 --- a/docs/classes/PgSQL_Util.html +++ b/docs/classes/PgSQL_Util.html @@ -207,7 +207,7 @@
+ generated on 2012-04-30T16:05:55-04:00.
diff --git a/docs/classes/Query_Builder.html b/docs/classes/Query_Builder.html index a6d3e0c..e8e3d66 100644 --- a/docs/classes/Query_Builder.html +++ b/docs/classes/Query_Builder.html @@ -107,9 +107,11 @@ passed array with key / value pairs
where()
  • WHERE NOT IN (FOO) clause
    where_not_in()
  • String together the sql statements for sending to the db
    _compile()
  • +
  • Simplify 'like' methods
    _like()
  • Clear out the class variables, so the next query can be run
    _reset()
  • Method to simplify select_ methods
    _select()
  • Do all the repeditive stuff for where/having type methods
    _where()
  • +
  • Simplify where_in methods
    _where_in()
  • Convenience property for connection management
    $conn_name
  • @@ -949,6 +951,35 @@ passed array with key / value pairs
    \$string
    +
    +

    Simplify 'like' methods

    +
    _like(string $field, mixed $val, string $pos, string $like, string $conj) 
    +
    +
    +

    +

    Parameters

    +
    +

    $field

    +string +
    +
    +

    $val

    +mixed +
    +
    +

    $pos

    +string +
    +
    +

    $like

    +string +
    +
    +

    $conj

    +string +
    +
    +

    Clear out the class variables, so the next query can be run

    _reset() 
    @@ -993,6 +1024,29 @@ passed array with key / value pairs
    array
    +
    +

    Simplify where_in methods

    +
    _where_in(mixed $key, mixed $val, $in, $conj) : void
    +
    +
    +

    +

    Parameters

    +
    +

    $key

    +mixed +
    +
    +

    $val

    +mixed +
    +
    +

    $in

    +

    string

    +
    +

    $conj

    +

    string

    +
    +

     Properties

     
    @@ -1099,7 +1153,7 @@ for complex select queries
    + generated on 2012-04-30T16:05:55-04:00.
    diff --git a/docs/classes/SQLite.html b/docs/classes/SQLite.html index 0a919a4..8670f59 100644 --- a/docs/classes/SQLite.html +++ b/docs/classes/SQLite.html @@ -865,7 +865,7 @@ method if the database does not support 'TRUNCATE';
    + generated on 2012-04-30T16:05:55-04:00.
    diff --git a/docs/classes/SQLite_SQL.html b/docs/classes/SQLite_SQL.html index 34c84e2..62e0779 100644 --- a/docs/classes/SQLite_SQL.html +++ b/docs/classes/SQLite_SQL.html @@ -280,7 +280,7 @@
    + generated on 2012-04-30T16:05:55-04:00.
    diff --git a/docs/classes/SQLite_Util.html b/docs/classes/SQLite_Util.html index 9403fc3..cc3e3a4 100644 --- a/docs/classes/SQLite_Util.html +++ b/docs/classes/SQLite_Util.html @@ -207,7 +207,7 @@
    + generated on 2012-04-30T16:05:55-04:00.
    diff --git a/docs/classes/Settings.html b/docs/classes/Settings.html index e90e3a8..7599ff4 100644 --- a/docs/classes/Settings.html +++ b/docs/classes/Settings.html @@ -243,7 +243,7 @@ directly - the settings should be safe!
    + generated on 2012-04-30T16:05:55-04:00.
    diff --git a/docs/deprecated.html b/docs/deprecated.html index 1043183..1da18d5 100644 --- a/docs/deprecated.html +++ b/docs/deprecated.html @@ -66,7 +66,7 @@
    + generated on 2012-04-30T16:05:55-04:00.
    diff --git a/docs/errors.html b/docs/errors.html index 3ec6cc0..c8f5187 100644 --- a/docs/errors.html +++ b/docs/errors.html @@ -92,7 +92,7 @@
    + generated on 2012-04-30T16:05:55-04:00.
    diff --git a/docs/graph_class.html b/docs/graph_class.html index 8c13093..411da74 100644 --- a/docs/graph_class.html +++ b/docs/graph_class.html @@ -63,7 +63,7 @@
    + generated on 2012-04-30T16:05:55-04:00.
    diff --git a/docs/markers.html b/docs/markers.html index 3749b1d..d5a5acc 100644 --- a/docs/markers.html +++ b/docs/markers.html @@ -68,7 +68,7 @@
    + generated on 2012-04-30T16:05:55-04:00.
    diff --git a/docs/namespaces/default.html b/docs/namespaces/default.html index 6ad7e83..ce06727 100644 --- a/docs/namespaces/default.html +++ b/docs/namespaces/default.html @@ -264,15 +264,15 @@ instantiates the specific db driver

    Constants

    - 
    + 

    Reference to root path

    -
    BASE_PATH 
    +
    QBASE_PATH 

    - 
    + 

    Path to driver classes

    -
    DRIVER_PATH 
    +
    QDRIVER_PATH 

    @@ -282,7 +282,7 @@ instantiates the specific db driver

    + generated on 2012-04-30T16:05:55-04:00.
    diff --git a/docs/packages/.html b/docs/packages/.html index b2444e8..df037ed 100644 --- a/docs/packages/.html +++ b/docs/packages/.html @@ -66,7 +66,7 @@
    + generated on 2012-04-30T16:05:55-04:00.
    diff --git a/docs/packages/Default.html b/docs/packages/Default.html index 6a92425..b9416b2 100644 --- a/docs/packages/Default.html +++ b/docs/packages/Default.html @@ -61,8 +61,8 @@ -
  • Reference to root path
    BASE_PATH
  • -
  • Path to driver classes
    DRIVER_PATH
  • +
  • Reference to root path
    QBASE_PATH
  • +
  • Path to driver classes
    QDRIVER_PATH
  • @@ -75,15 +75,15 @@

    Constants

    - 
    + 

    Reference to root path

    -
    BASE_PATH 
    +
    QBASE_PATH 

    - 
    + 

    Path to driver classes

    -
    DRIVER_PATH 
    +
    QDRIVER_PATH 

    @@ -93,7 +93,7 @@
    + generated on 2012-04-30T16:05:55-04:00.
    diff --git a/docs/packages/Query.Drivers.html b/docs/packages/Query.Drivers.html index f25ba68..87a898b 100644 --- a/docs/packages/Query.Drivers.html +++ b/docs/packages/Query.Drivers.html @@ -210,7 +210,7 @@ data-fetching methods

    + generated on 2012-04-30T16:05:55-04:00.
    diff --git a/docs/packages/Query.Helper Classes.html b/docs/packages/Query.Helper Classes.html index bd54869..a557f2c 100644 --- a/docs/packages/Query.Helper Classes.html +++ b/docs/packages/Query.Helper Classes.html @@ -96,7 +96,7 @@
    + generated on 2012-04-30T16:05:55-04:00.
    diff --git a/docs/packages/Query.Query.html b/docs/packages/Query.Query.html index 6298c6b..c546f70 100644 --- a/docs/packages/Query.Query.html +++ b/docs/packages/Query.Query.html @@ -114,7 +114,7 @@ instantiates the specific db driver

    + generated on 2012-04-30T16:05:55-04:00.
    diff --git a/docs/packages/Query.html b/docs/packages/Query.html index b760c47..22a7e1a 100644 --- a/docs/packages/Query.html +++ b/docs/packages/Query.html @@ -315,7 +315,7 @@ instantiates the specific db driver

    + generated on 2012-04-30T16:05:55-04:00.
    diff --git a/docs/structure.xml b/docs/structure.xml index a86d8f6..1e35815 100644 --- a/docs/structure.xml +++ b/docs/structure.xml @@ -934,7 +934,7 @@ the connection/database]]> - + Free Query Builder / Database Abstraction Layer

    ]]>
    @@ -1327,11 +1327,11 @@ for complex select queries]]> - - like + + _like function - + string @@ -1342,811 +1342,898 @@ for complex select queries]]> string - - \$this + + string + + + string - + $field - + $val - + + $pos + + + + + $like + + + + + $conj + + + + + + like + function + + + + + string + + + mixed + + + string + + + \$this + + + + $field + + + + + $val + + + + $pos - + or_like function - + - + string - + mixed - + string - + \$this - + $field - + $val - + $pos - + not_like function - + - + string - + mixed - + string - + \$this - + $field - + $val - + $pos - + or_not_like function - + - + string - + mixed - + string - + \$this - + $field - + $val - + $pos - + having function - + - + mixed - + mixed - + \$this - + $key - + $val - + or_having function - + - + mixed - + mixed - + \$this - + $key - + $val - + _where function - + - + mixed - + mixed - + array - + $key - + $val - + + _where_in + function + + + + + mixed + + + mixed + + + + + void + + + + $key + + + + + $val + + + + + $in + + + + + $conj + + + + + where function - + - + mixed - + mixed - + \$this - + $key - + $val - + or_where function - + - + string - + mixed - + \$this - + $field - + $val - + where_in function - + - + mixed - + mixed - + \$this - + $field - + $val - + or_where_in function - + - + string - + mixed - + \$this - + $field - + $val - + where_not_in function - + - + string - + mixed - + \$this - + $field - + $val - + or_where_not_in function - + - + string - + mixed - + \$this - + $field - + $val - + set function - + - + mixed - + mixed - + \$this - + $key - + $val - + join function - + - + string - + string - + string - + \$this - + $table - + $condition - + $type - + group_by function - + - + mixed - + \$this - + $field - + order_by function - + - + string - + string - + \$this - + $field - + $type - + limit function - + - + int - + int - + string - + $limit - + $offset - + group_start function - + - + \$this - + or_group_start function - + - + \$this - + or_not_group_start function - + - + \$this - + group_end function - + - + \$this - + get function - + - - + + int - + int - + object - + $table - + $limit - + $offset - + get_where function - + - + string - + array - + int - + int - + object - + $table - + $where - + $limit - + $offset - + count_all function - + - + string - + int - + $table - + count_all_results function - + - + string - + int - + $table - + insert function - + - + string - + mixed - + mixed - + $table - + $data - + update function - + - + string - + mixed + + mixed + + + + $table + + + + + $data + + + + + + delete + function + + + + + string + + + mixed + + + mixed + + + + $table + + + + + $where + + + + + + __call + function + + + + + string + + + array + mixed - $table - - - - - $data - - - - - - delete - function - - - - - string - - - mixed - - - mixed - - - - $table - - - - - $where - - - - - - __call - function - - - - - string - - - array - - - mixed - - - $name - + $params - + _reset function - + - + _compile function - + - + string - + string - + \$string - + $type - + $table @@ -2312,7 +2399,7 @@ in place of the get() method]]>
    - + Free Query Builder / Database Abstraction Layer

    ]]>
    @@ -2323,7 +2410,7 @@ in place of the get() method]]>
    - BASE_PATH + QBASE_PATH @@ -2331,8 +2418,8 @@ in place of the get() method]]> - DRIVER_PATH - + QDRIVER_PATH + diff --git a/tests/TEST_DIRDSdb_filesDStest_sqlite.db b/tests/TEST_DIRDSdb_filesDStest_sqlite.db new file mode 100644 index 0000000000000000000000000000000000000000..c30be70b779464434076ee614e850905cb511c15 GIT binary patch literal 3072 zcmWFz^vNtqRY=P(%1ta$FlJz3U}R))P*7lCVBiH}W*~+ECLn_a#sSidNNik8UIyJq zN+5%nm{k~U zq~_)4>6YggrEqYuFbE178X21KF|ja+ivz{7ixYE-^X&x~Ss0|nlk)S^Q;Uk-i}H($ XLHQr0Rv%J6A9d_#2#kgRB_RL+qUK-o literal 0 HcmV?d00001 diff --git a/tests/databases/firebird/firebird-qb.php b/tests/databases/firebird/firebird-qb.php index a823623..a3b01f1 100644 --- a/tests/databases/firebird/firebird-qb.php +++ b/tests/databases/firebird/firebird-qb.php @@ -22,7 +22,7 @@ class FirebirdQBTest extends QBTest { { parent::__construct(); - $dbpath = TEST_DIR.DS.'db_files'.DS.'FB_TEST_DB.FDB'; + $dbpath = QTEST_DIR.QDS.'db_files'.QDS.'FB_TEST_DB.FDB'; // Test the query builder $params = new Stdclass(); diff --git a/tests/databases/firebird/firebird.php b/tests/databases/firebird/firebird.php index bac5f8962..5247389 100644 --- a/tests/databases/firebird/firebird.php +++ b/tests/databases/firebird/firebird.php @@ -22,7 +22,7 @@ class FirebirdTest extends DBTest { public function setUp() { - $dbpath = TEST_DIR.DS.'db_files'.DS.'FB_TEST_DB.FDB'; + $dbpath = QTEST_DIR.QDS.'db_files'.QDS.'FB_TEST_DB.FDB'; // Test the db driver directly $this->db = new Firebird('localhost:'.$dbpath); diff --git a/tests/databases/mysql/mysql-qb.php b/tests/databases/mysql/mysql-qb.php index b014649..eb67128 100644 --- a/tests/databases/mysql/mysql-qb.php +++ b/tests/databases/mysql/mysql-qb.php @@ -20,9 +20,9 @@ class MySQLQBTest extends QBTest { parent::__construct(); // Attempt to connect, if there is a test config file - if (is_file(BASE_DIR . "test_config.json")) + if (is_file(QBASE_DIR . "test_config.json")) { - $params = json_decode(file_get_contents(BASE_DIR . "test_config.json")); + $params = json_decode(file_get_contents(QBASE_DIR . "test_config.json")); $params = $params->mysql; $params->type = "mysql"; diff --git a/tests/databases/mysql/mysql.php b/tests/databases/mysql/mysql.php index 1562bc5..f1f0f90 100644 --- a/tests/databases/mysql/mysql.php +++ b/tests/databases/mysql/mysql.php @@ -23,9 +23,9 @@ class MySQLTest extends DBTest { public function setUp() { // Attempt to connect, if there is a test config file - if (is_file(BASE_DIR . "test_config.json")) + if (is_file(QBASE_DIR . "test_config.json")) { - $params = json_decode(file_get_contents(BASE_DIR . "test_config.json")); + $params = json_decode(file_get_contents(QBASE_DIR . "test_config.json")); $params = $params->mysql; $this->db = new MySQL("host={$params->host};port={$params->port};dbname={$params->database}", $params->user, $params->pass); diff --git a/tests/databases/pgsql/pgsql-qb.php b/tests/databases/pgsql/pgsql-qb.php index e763b08..295e51a 100644 --- a/tests/databases/pgsql/pgsql-qb.php +++ b/tests/databases/pgsql/pgsql-qb.php @@ -19,9 +19,9 @@ class PgSQLQBTest extends QBTest { parent::__construct(); // Attempt to connect, if there is a test config file - if (is_file(BASE_DIR . "test_config.json")) + if (is_file(QBASE_DIR . "test_config.json")) { - $params = json_decode(file_get_contents(BASE_DIR . "test_config.json")); + $params = json_decode(file_get_contents(QBASE_DIR . "test_config.json")); $params = $params->pgsql; $params->type = "pgsql"; diff --git a/tests/databases/pgsql/pgsql.php b/tests/databases/pgsql/pgsql.php index 80e6a61..dfb9f56 100644 --- a/tests/databases/pgsql/pgsql.php +++ b/tests/databases/pgsql/pgsql.php @@ -29,9 +29,9 @@ class PgTest extends DBTest { public function setUp() { // Attempt to connect, if there is a test config file - if (is_file(BASE_DIR . "test_config.json")) + if (is_file(QBASE_DIR . "test_config.json")) { - $params = json_decode(file_get_contents(BASE_DIR . "test_config.json")); + $params = json_decode(file_get_contents(QBASE_DIR . "test_config.json")); $params = $params->pgsql; $this->db = new PgSQL("host={$params->host};port={$params->port};dbname={$params->database}", $params->user, $params->pass); diff --git a/tests/databases/sqlite/sqlite-qb.php b/tests/databases/sqlite/sqlite-qb.php index 1ea5e55..81b853f 100644 --- a/tests/databases/sqlite/sqlite-qb.php +++ b/tests/databases/sqlite/sqlite-qb.php @@ -21,7 +21,7 @@ { parent::__construct(); - $path = TEST_DIR.DS.'db_files'.DS.'test_sqlite.db'; + $path = QTEST_DIR.QDS.'db_files'.QDS.'test_sqlite.db'; $params = new Stdclass(); $params->type = 'sqlite'; $params->file = $path; diff --git a/tests/databases/sqlite/sqlite.php b/tests/databases/sqlite/sqlite.php index cd976a8..74860bf 100644 --- a/tests/databases/sqlite/sqlite.php +++ b/tests/databases/sqlite/sqlite.php @@ -28,7 +28,7 @@ class SQLiteTest extends UnitTestCase { public function setUp() { - $path = TEST_DIR.DS.'db_files'.DS.'test_sqlite.db'; + $path = QTEST_DIR.QDS.'db_files'.QDS.'test_sqlite.db'; $this->db = new SQLite($path); } diff --git a/tests/db_files/FB_TEST_DB.FDB b/tests/db_files/FB_TEST_DB.FDB index 59d46e820372a27a66454520eaa37aa7e3fdd249..a52f6a38105d186b4f038d1c41b00fe1a520805f 100644 GIT binary patch delta 838 zcmaix&ubGw6vyA2-A%W7B%QVjfl}RV5>u&#EGCE|iZ?GF#8N#;{fP%bFhv#(x_DST zc(5Q0DEnmVBy4<%GZKs011MhrDTmfHd~z+*5R?0rI$}-C^3{G zltw7cP+FnPgmNU5b|^>JW!97!v@9ok%r*vt!P>>oBVjeWUL|w&>J>Yww>vE2B=oQh zJ=1}2<_tVDXW_J2hVzC4C4!KzsVFpBV9%)&cS1fO#^Irm(Y;SR5L#Fzs|w63=) z#BuFvBS|A5`)H~+ZE_Dx^no|huz3RYjI^<@k z4^aD{K1Ni+ruxN`n(k5sAFFyy?u}db)2c#O<x0n9{f}*Cl delta 1000 zcma)4&ubGw6n?YGc4zYp9hG9hAKf-hlY=E)x*`hFKcJOT)LJA+Drzs%l%`;h!Ncmo zgMu&x^-mD=;vR%*!K0vOQAmPl4w{^VURHdwlSzvw->@_L&D(k3`@Y#m!*4YFiww?9 zzZrx55ZFldky_V1fI2+@7JK>`;PTmz#ZNhf0R&hys>wT}c|B@9vPXv>SD)MyphMEmbnK39|ytn&~Zwz&9m^%&BFs)-#dADMrSq&ZxL3pHDGL~lV7KZ4D6EjuW3b)ak+dXhEYwVX0C*}=|qtFVThD*SgWl~ z-K}lh1UjTHqbOn^V1lVb{SH-^>JWo7@q&Eu6DLXs%G*hK)ggf0|I#KO>$O=bt?pCC zZ7i}y?L+#1d@#E7-z5e*jprt>ePJ-?Y2Q?zYRn}*4FBVU{QVtY$@4AD$(cdz~hP$s8z diff --git a/tests/index.php b/tests/index.php index 9beadf3..bc4550b 100644 --- a/tests/index.php +++ b/tests/index.php @@ -16,27 +16,27 @@ /** * Unit test bootstrap - Using php simpletest */ -define('TEST_DIR', dirname(__FILE__)); -define('BASE_DIR', str_replace(basename(TEST_DIR), '', TEST_DIR)); -define('DS', DIRECTORY_SEPARATOR); +define('QTEST_DIR', dirname(__FILE__)); +define('QBASE_DIR', str_replace(basename(QTEST_DIR), '', QTEST_DIR)); +define('QDS', DIRECTORY_SEPARATOR); // Include simpletest // it has to be set in your php path, or put in the tests folder require_once('simpletest/autorun.php'); // Include db classes -require_once(BASE_DIR . 'autoload.php'); +require_once(QBASE_DIR . 'autoload.php'); // Require base testing classes -require_once(TEST_DIR . '/core/core.php'); -require_once(TEST_DIR . '/core/settings.php'); -require_once(TEST_DIR . '/core/db_test.php'); -require_once(TEST_DIR . '/core/db_qb_test.php'); +require_once(QTEST_DIR . '/core/core.php'); +require_once(QTEST_DIR . '/core/settings.php'); +require_once(QTEST_DIR . '/core/db_test.php'); +require_once(QTEST_DIR . '/core/db_qb_test.php'); // Include db tests // Load db classes based on capability -$src_path = BASE_DIR.'drivers/'; -$test_path = TEST_DIR.'/databases/'; +$src_path = QBASE_DIR.'drivers/'; +$test_path = QTEST_DIR.'/databases/'; foreach(pdo_drivers() as $d) {