add some simple tests for the WhereClause system, which will now be official and documented

This commit is contained in:
Sergey Tsalkov
2011-09-23 18:44:34 -07:00
parent a2800ef04b
commit 9f3aa571dc
3 changed files with 36 additions and 7 deletions

View File

@@ -62,7 +62,7 @@ class DB
return $mysql;
}
protected static function nonSQLError($message) {
public static function nonSQLError($message) {
if (DB::$throw_exception_on_nonsql_error) {
$e = new MeekroDBException($message);
throw $e;
@@ -564,7 +564,9 @@ class WhereClause {
public $clauses = array();
function __construct($type) {
$this->type = strtolower($type);
$type = strtolower($type);
if ($type != 'or' && $type != 'and') DB::nonSQLError('you must use either WhereClause(and) or WhereClause(or)');
$this->type = $type;
}
function add() {
@@ -598,11 +600,8 @@ class WhereClause {
return count($this->clauses);
}
function text($minimal = false) {
if (count($this->clauses) == 0) {
if ($minimal) return '(1)';
else return '';
}
function text() {
if (count($this->clauses) == 0) return '(1)';
$A = array();
foreach ($this->clauses as $clause) {