Answer the question
In order to leave comments, you need to log in
How to force CDbCriteria to perform a distinct query on one field, and not on all?
Good evening.
I pull up the data through Active Record, as an object with conditions I use the CDBCriteria object.
$criteria = new CDbCriteria();
$criteria->distinct = true;
$criteria->select = 'id, alias, title';
$criteria->condition = "urlrouting_show <> 0";
$criteria->order = 'title ASC';
return $this->findAll($criteria);
SELECT DISTINCT(title), id, alias FROM table
SELECT DISTINCT id, alias, title FROM table
Answer the question
In order to leave comments, you need to log in
$criteria = new CDbCriteria();
$criteria->select = ['id','alias','DISTINCT(title)'];
$criteria->condition = "urlrouting_show <> 0";
$criteria->order = 'title ASC';
return $this->findAll($criteria);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question