public function testClause() { $statement = new QueryStatement(); $this->assertFalse($statement->hasClause('SELECT')); $select = new SelectClause(); $statement->addClause($select); $this->assertSame($select, $statement->getClause('SELECT')); $this->assertTrue($statement->hasClause('SELECT')); $statement->removeClause('SELECT'); $this->assertFalse($statement->hasClause('SELECT')); }
/** * Find all distinct values of a property in the collection * * @param $property * * @return array */ public function distinct($property) { if ($this->isEmpty()) { $select = new SelectClause(); $select->setDistinct(true); $select->addField($property); $originalClause = $this->_query->getClause('SELECT'); $this->_query->addClause($select); $results = $this->_getDataStore()->getData($this->_query); $this->_query->addClause($originalClause); if (empty($results)) { return []; } return Arrays::ipull($results, $property); } return parent::distinct($property); }