CakePHP的分页现有find()方法操作
我觉得有点晚了关于我的CakePHP项目中的分页,所以我现在所存在的(复杂)HABTM发现操作(动态秩序,标签搜索等)是有可能做一个CakePHP的分页在这一点上?或者是更好/更容易由我自己来做分页(查找下一个20条目ID XX ......)? 我搜索了很久的一个解决方案,但实际上我已经什么也没有发现有用的
I thought a bit too late about the pagination in my cakephp project, so now I have existing (complex) HABTM find operations (with dynamic order, tag search etc..) is it possible to do a cakephp pagination at this point? Or is it better/easier to do the pagination by my own (find next 20 entries from ID xx...)? I've searched a long time for a solution but actually i've found nothing useful
不管你做什么,你做多么复杂的应用程序,你只需要一些改变,使分页,我有相同的,请我实现的解决方案。
No matter what you do , how complex app you make , you just need some syntax changes to make pagination , I had same , please check the solution i implemented.
$conditionSearchLessonsByCourse = array('CourseLessonsReference.is_active'=>1,
'Course1.is_active'=>1 ,
'CourseCategory.is_active'=>1,
'Reference.is_active'=>1
);
//Pagination logic
$this->paginate = array('conditions' => $conditionSearchLessonsByCourse,
'order' =>'CourseLessonsReference.id DESC',
'limit' => PAGINATION_LIMIT,
"joins" => array(
array(//UserCourse = Course Join
"table" => "courses",
"alias" => "Course1",
"type" => "INNER",
"conditions" => array(
"Course1.id = CourseLessonsReference.course_id"
)
),//For Category = Course Join
array(
"table" => "course_categories",
"alias" => "CourseCategory",
"type" => "INNER",
"conditions" => array(
"CourseCategory.id = Course1.course_category_id"
)
)
),
'recursive' => 2
);
$allLessonReferences = $this->paginate('CourseLessonsReference');