0
向包含連接語句的activerecord查詢添加限制的正確方法是什麼?我已經有一個ActiveRecord加入其轉換爲正確的SQLphpactiverecord加入限制
static $belongs_to = array(
array('job_request')
);
$requests = $this->all(array(
'joins' => array('job_request'),
'conditions' => array('DATE(job_date) >= ? AND DATE(job_date) <= ? AND'
. ' user_id = ?', $start_date, $end_date, $userid))
);
把它轉換成SQL作爲
SELECT `job_applications`.* FROM `job_applications` INNER JOIN `job_requests`
ON(`job_applications`.job_request_id = `job_requests`.id) WHERE
DATE(job_date) >= '2013-01-28' AND DATE(job_date) <= '2013-03-04'
AND user_id = '1'
,但如果我增加一個限制,該連接是從SQL查詢
刪除聲明$requests = $this->all(array(
'joins' => array('job_request'),
'conditions' => array('DATE(job_date) >= ? AND DATE(job_date) <= ? AND'
. ' user_id = ?', $start_date, $end_date, $userid)),
array('limit' => 200, 'offset' => 0)
);
生成
SELECT * FROM `job_applications` LIMIT 0,999999