我有2个控制器
Model Customer.php
public $hasMany = array(
"Ticket" => array(
'className' => 'Ticket',
'foreignKey' => 'customer_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);
现在我正在尝试获取Ticket.status < 2
我正在客户控制器中尝试此查询。
$this->paginate = array(
'conditions' => array(
"OR"=>array(
"Customer.created >"=> date("Y-m-d H:i:s", strtotime("-1 month")),
"Ticket.status <"=> 2,
)
),
'limit' => 10,
'order' => array('Customer.created'=>'DESC')
);
但它不起作用。
答案 0 :(得分:0)
$this->paginate = array(
'conditions' => array(
"Customer.created >"=> date("Y-m-d H:i:s", strtotime("-1 month")),
),
'contain' => array('Ticket' => array('conditions'=> array("Ticket.status <" => 2))),
'limit' => 10,
'order' => array('Customer.created'=>'DESC')
);
只需尝试以上查询并分享结果即可。