Itu karena group by
Saya menemukan solusi. Saya ingin memasang tautan tetapi saya kehilangannya, jadi saya akan memposting kode:
public function paginateCount($conditions = null, $recursive = 0, $extra = array()) {
$parameters = compact('conditions', 'recursive');
if (isset($extra['group'])) {
$parameters['fields'] = $extra['group'];
if (is_string($parameters['fields'])) {
// pagination with single GROUP BY field
if (substr($parameters['fields'], 0, 9) != 'DISTINCT ') {
$parameters['fields'] = 'DISTINCT ' . $parameters['fields'];
}
unset($extra['group']);
$count = $this->find('count', array_merge($parameters, $extra));
} else {
// resort to inefficient method for multiple GROUP BY fields
$count = $this->find('count', array_merge($parameters, $extra));
$count = $this->getAffectedRows();
}
} else {
// regular pagination
$count = $this->find('count', array_merge($parameters, $extra));
}
return $count;
}
Saya menambahkannya di app_model dan berfungsi dengan baik untuk saya :)
Semoga membantu
Diedit: Saya menemukan tautan =)
http://wiltonsoftware.com/posts /view/custom-group-by-pagination-and-a-calculated-field