【发布时间】:2011-06-11 14:23:54
【问题描述】:
假设我有一个名为“products”的表和一个名为“Product”的模型。
'products' 表有 3 个字段 id,title,price,created
我想计算 cal_price(每条记录和搜索日期不同)并创建一个临时表,其中包含 4 个字段,即 id、title、price、cal_price,按 cal_price 排序
现在,我只想为这个临时表分页。
使用 $this->paginate();
例如。
table_products
id title price created
3 demo1 23 2011-12-12
4 demo2 43 2011-12-13
56 demo3 26 2011-12-16
按 cal_price 排序“temp_table”订单并分页
temp_table
id title price cal_price created
3 demo1 23 12 2011-12-12
4 demo2 43 43 2011-12-13
56 demo3 26 88 2011-12-16
*解决方案的根本问题是如何在运行时将 temp_table 分配给模型,因为一旦我这样做了,我就可以使用 $this->paginate('temp_model') 来解决问题*
【问题讨论】:
标签: php cakephp model pagination temp-tables