Skip to content

Commit 151ef44

Browse files
committed
Merge pull request #386 from g4ther/master
Fixed Having
2 parents e29e28e + 3976dcd commit 151ef44

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

MysqliDb.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -784,13 +784,19 @@ public function orWhere($whereProp, $whereValue = 'DBNULL', $operator = '=')
784784
* @return MysqliDb
785785
*/
786786

787-
public function having($havingProp, $havingValue = null, $operator = null)
787+
public function having($havingProp, $havingValue = 'DBNULL', $operator = '=', $cond = 'AND')
788788
{
789-
if ($operator) {
790-
$havingValue = array($operator => $havingValue);
789+
// forkaround for an old operation api
790+
if (is_array($havingValue) && ($key = key($havingValue)) != "0") {
791+
$operator = $key;
792+
$havingValue = $havingValue[$key];
793+
}
794+
795+
if (count($this->_having) == 0) {
796+
$cond = '';
791797
}
792798

793-
$this->_having[] = array("AND", $havingValue, $havingProp);
799+
$this->_having[] = array($cond, $havingProp, $operator, $havingValue);
794800
return $this;
795801
}
796802

@@ -807,12 +813,7 @@ public function having($havingProp, $havingValue = null, $operator = null)
807813
*/
808814
public function orHaving($havingProp, $havingValue = null, $operator = null)
809815
{
810-
if ($operator) {
811-
$havingValue = Array($operator => $havingValue);
812-
}
813-
814-
$this->_having[] = Array("OR", $havingValue, $havingProp);
815-
return $this;
816+
return $this->having($havingProp, $havingValue, $operator, 'OR');
816817
}
817818

818819
/**

0 commit comments

Comments
 (0)