Using the builder:
The main implementation for the following example:
$queryBuilder = $this->getDI()->getModelsManager() ->createBuilder() ->addFrom('tableName', 't');
Distinctive team:
$queryBuilder->distinct('t.id');
The column also works, but is not recommended:
$queryBuilder->columns('DISTINCT(t.id) AS id')
Using strictly models:
// we are waiting for it, but may still not be implemented TableModel::find(array('distinct' => 'id'))
To count:
TableModel::count(array("distinct" => "id"));
And a less recommended method according to the previous answer:
TableModel::find(array('columns' => 'distinct(id)'))
And a link to imo best docs .
In addition, there are some problems in Phalcon 2.0.2 .
source share