php - Phalcon: how to get distinct models? -


using phalcon model, how can distinct rows when rows using find() method.

using builder:

basic implementation later example:

    $querybuilder = $this->getdi()->getmodelsmanager()         ->createbuilder()         ->addfrom('tablename', 't'); 

distinct command:

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

column thing works too, not recommended:

    $querybuilder->columns('distinct(t.id) id') 

using strictly model:

   // waiting it, may still not implemented    tablemodel::find(array('distinct' => 'id')) 

for count:

   tablemodel::count(array("distinct" => "id")); 

and less recommended way according previous answer:

   tablemodel::find(array('columns' => 'distinct(id)')) 

and link imo best docs.

also, there issues in phalcon 2.0.2.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -