lithium\data\model\Query::having PHP Method

having() public method

Set and get _having_.
public having ( mixed $having = null ) : string | Query
$having mixed String or array to append to existing having.
return string | Query Either the currrent _having_ when $having is `null` or the query itself when setting _having_.
    public function having($having = null)
    {
        if (!$having) {
            return $this->_config['having'];
        }
        $this->_config['having'] = array_merge((array) $this->_config['having'], (array) $having);
        return $this;
    }

Usage Example

Example #1
0
 public function testHaving()
 {
     $query = new Query($this->_queryArr);
     $expected = array();
     $result = $query->having();
     $this->assertEqual($expected, $result);
     $query->having(array('count' => 5));
     $expected = array('count' => 5);
     $result = $query->having();
     $this->assertEqual($expected, $result);
 }