aboutsummaryrefslogtreecommitdiff
path: root/h-source/Library/Model/Base.php
diff options
context:
space:
mode:
Diffstat (limited to 'h-source/Library/Model/Base.php')
-rwxr-xr-xh-source/Library/Model/Base.php25
1 files changed, 22 insertions, 3 deletions
diff --git a/h-source/Library/Model/Base.php b/h-source/Library/Model/Base.php
index c89abcd..57d769a 100755
--- a/h-source/Library/Model/Base.php
+++ b/h-source/Library/Model/Base.php
@@ -236,7 +236,7 @@ abstract class Model_Base
//method to create the where clause of the select query from the $this->where array
//$level: level of the ricorsion
//$whereClauseLevel: array containing the field=>value statements of the where clause. If $whereClause = null than $this->where is considered
- public function createWhereClause($level = 0, $whereClauseLevel = null)
+ public function createWhereClause($level = 0, $whereClauseLevel = null, $operator = null)
{
$whereClause = null;
$whereClauseArray = array();
@@ -247,7 +247,19 @@ abstract class Model_Base
{
if (is_array($value))
{
- $newValue = $this->createWhereClause($level+1, $value);
+ if (strstr($field,"OR"))
+ {
+ $op = " OR ";
+ }
+ else if (strstr($field,"AND"))
+ {
+ $op = " AND ";
+ }
+ else
+ {
+ $op = null;
+ }
+ $newValue = $this->createWhereClause($level+1, $value, $op);
if (isset($newValue)) $whereClauseArray[] = $newValue;
}
else
@@ -283,7 +295,14 @@ abstract class Model_Base
}
}
//get the logic operator at the current level
- $logicOper = isset($this->logicalOperators[$level]) ? ' '.$this->logicalOperators[$level].' ' : ' AND ';
+ if (isset($operator))
+ {
+ $logicOper = $operator;
+ }
+ else
+ {
+ $logicOper = isset($this->logicalOperators[$level]) ? ' '.$this->logicalOperators[$level].' ' : ' AND ';
+ }
$whereClause = !empty($whereClauseArray) ? implode($logicOper,$whereClauseArray) : null;
$whereClause = (isset($whereClause) and $level>0) ? '('.$whereClause.')' : $whereClause;
return $whereClause;