Skip to content

Commit

Permalink
Reusing code for having() and friends
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Jan 10, 2013
1 parent e0ac0e7 commit 70b416b
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lib/Cake/Model/Datasource/Database/Query.php
Expand Up @@ -347,18 +347,21 @@ public function group($fields, $overwrite = false) {
return $this;
}

public function having($field, $value = null) {
$this->_parts['having']->andWhere($field, $value);
public function having($conditions = null, $types = [], $overwrite = false) {
if ($overwrite) {
$this->_parts['having'] = $this->newExpr();
}
$this->_conjugate('having', $conditions, 'AND', $types);
return $this;
}

public function andHaving($field, $value = null) {
$this->having($field, $value);
public function andHaving($conditions, $types = []) {
$this->_conjugate('having', $conditions, 'AND', $types);
return $this;
}

public function orHaving($field, $value = null) {
$this->_parts['having']->orWhere($field, $value);
public function orHaving($conditions, $types = []) {
$this->_conjugate('having', $conditions, 'OR', $types);
return $this;
}

Expand Down

0 comments on commit 70b416b

Please sign in to comment.