我在我的控制器中有这个动作(buy_it_packages_controller):
function admin_index()
{
$this->paginate = array('contain' => array('User', 'Auction'), 'limit' => 10, 'order' => array('created' => 'desc'));
$this->set('packages', $this->paginate());
}
购买套餐与用户和拍卖之间存在链接。
问题是我需要从Bid模型中为上面的paginate调用中的每一行返回一列。要为特定拍卖执行此操作,我使用用户ID和拍卖ID,如下所示:
$bidCount = $this->Auction->Bid->find('all', array('contain' => '', 'conditions' => array('auction_id' => $id, 'user_id' => $this->Auth->user('id')), 'fields' => array('SUM(debit) as sumofbids'), 'group' => 'auction_id'));
我如何在分页查询中执行此操作?
购买它的包模型有拍卖ID列 出价模型有auction_id列 但是买包模型和投标模型之间没有直接联系。
答案 0 :(得分:0)
function admin_index()
{
$this->paginate = array('contain' => array('User', 'Auction' => array('Bid'), 'limit' => 10, 'order' => array('created' => 'desc'));
$this->set('packages', $this->paginate());
}