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

group() public method

Set and get method for the Query group config setting.
public group ( string | array | null $group = null ) : array | null | lithium\data\Query
$group string | array | null
return array | null | lithium\data\Query
    public function group($group = null)
    {
        if ($group) {
            $this->_config['group'] = $group;
            return $this;
        }
        if ($group === false) {
            $this->_config['group'] = null;
            return $this;
        }
        return $this->_config['group'];
    }

Usage Example

Example #1
0
 /**
  * Tests basic property accessors and mutators.
  *
  * @return void
  */
 public function testBasicAssignments()
 {
     $query = new Query();
     $group = array('key' => 'hits', 'reduce' => 'function() {}');
     $calculate = 'count';
     $this->assertNull($query->group());
     $query->group($group);
     $this->assertEqual($group, $query->group());
     $this->assertNull($query->calculate());
     $query->calculate($calculate);
     $this->assertEqual($calculate, $query->calculate());
     $query = new Query(compact('calculate', 'group'));
     $this->assertEqual($group, $query->group());
     $this->assertEqual($calculate, $query->calculate());
 }