As we all might know that selecting all records from the database in cakephp can be done using the find("all") method, But there are chances of duplicate records may appear.
To remove the duplicate records on selecting all records we use distinct keyword in the query but in cakephp here is a way to write it as :
$results = $this->LogfileRecord->find('all',
array('fields'=>array('DISTINCT date'),
'order'=>array('date DESC'))
);
in the above we have used distinct keyword in the array for date field. If we look for the simple query it will be as :
select distinct(date) from logfile_records order by date DESC;
0 Comment(s)