cakephp Paginator - >排序 - 模型选项 [英] cakephp Paginator -> sort - model option

查看:112
本文介绍了cakephp Paginator - >排序 - 模型选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一些问题,通过不同模型的字段对表数据进行排序。



从这里开始: http://book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html



它说我可以添加'model'选项,但是当我尝试:

 code> echo $ this-> Paginator-> sort('unit','Unit',array('model'=>'Unit')) 

我收到此错误:

 警告(2):array_filter()期望参数1为数组,给定[CORE / Cake / View / Helper / PaginatorHelper.php,395行] 

警告(2):array_merge()[function.array-merge]:参数#1不是数组[CORE / Cake / View / Helper / PaginatorHelper.php,395行]
/ pre>

任何想法这里发生了什么?



感谢

解决方案

如果您在某些表格的列表中显示记录,则可以通过以下方式使用:

 <?php echo $ this-> Paginator-> sort('Unit.unit','Unit'); 

无需传递第三个参数模型选项。


I am having some issues sorting the table data by a field of a different model.

From here: http://book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html

It says I can add in the 'model' option but when I try:

echo $this->Paginator->sort('unit', 'Unit', array('model' => 'Unit'));

I get this error:

Warning (2): array_filter() expects parameter 1 to be array, null given [CORE/Cake/View/Helper/PaginatorHelper.php, line 395]

Warning (2): array_merge() [function.array-merge]: Argument #1 is not an array [CORE/Cake/View/Helper/PaginatorHelper.php, line 395]

Any idea what is going on here? The Main / default model is Card and I need to order by the Unit model for one of the column headings.

Thanks

解决方案

If you are showing records in a list out of some tables, then you can use it via:

<?php echo $this->Paginator->sort('Unit.unit', 'Unit');

It will perfectly work without passing third argument model option.

这篇关于cakephp Paginator - &gt;排序 - 模型选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆