Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Option for function distinct phalcon/mvc/collection

Hello I'm using phalcon Framework.

I need to make a find, normally I would use distinct, but I not found an option.

My class as below :

class Calls extends \Phalcon\Mvc\Collection {
public $agent;
public $number;
public $date;
public $status;
}

I need to use distinct fields date and number ?

like image 634
murillo.zampieri Avatar asked Nov 10 '22 13:11

murillo.zampieri


1 Answers

you should use query builder:

Basic implementation for later example:

$queryBuilder = $this->getDI()->getModelsManager()
    ->createBuilder()
    ->addFrom('tableName', 't');

Distinct command:

$queryBuilder->distinct('t.id');

Column thing works too, but not recommended:

$queryBuilder->columns('DISTINCT(t.id) AS id')
like image 191
Mahdi Mohammadi Avatar answered Nov 15 '22 11:11

Mahdi Mohammadi