我在控制器中创建了以下功能:
function beg($status_id = null) {
if(!empty($status_id)){
$conditions = array('winner_id >' => 0, 'Product.beginner' => '1', 'Product.status_id' => $status_id);
}else{
$conditions = array('winner_id >' => 0, 'Product.beginner' => '1');
}
$this->paginate = array('conditions' => $conditions, 'limit' => $this->appConfigurations['adminPageLimit'], 'order' => array('end_time' => 'asc'), 'contain' => array('Product' => array('Category'), 'Status', 'Winner'));
$this->set('products', $this->paginate('Product'));
$this->set('statuses', $this->Product->Status->find('list'));
$this->set('selected', $status_id);
$this->set('extraCrumb', array('title' => __('Product List', true), 'url' => 'beg'));
$this->render('beg');
}
我想在其中再添加一个条件,即:
从Accounts 表中搜索winner_id 与accounts 表中的'user_id' 匹配,并且只在Accounts 表中获胜者ID 的列表中添加产品(accounts 表中的'user_id')。
任何人都知道如何添加条件$conditions = array('winner_id >' => 0, 'Product.beginner' => '1', 'Product.status_id' => $status_id);
我添加了更多条件,如下所示
$acc_id = $this->Account->find('all', array('Account.user_id'));
$conditions += array('Product.winner_id' => $acc_id);
但它不起作用,请任何人告诉我我哪里出错了