我試圖用笨的活動記錄做下面的SQL查詢:笨「其中」和「or_where」
SELECT * FROM USERS_OPTIONS WHERE user_id = 3 AND (option_id = 2 OR option_id = 5 OR option_id = 108 OR ....)
對於這一點,我在笨這段代碼,但它不是working:
$this -> db -> where("user_id", $user_id);
foreach($options as $option){
$this -> db -> or_where("option_id" , $option["id"] );
}
$ options是一個數組,我存儲所有我需要的options_id。
如果我單獨嘗試2個querys中的任何一個,它們就會工作。但我無法混合這兩個條件。
我怎樣才能得到這個?提前致謝。
downvoter請你解釋原因 – Pupil 2014-10-29 12:46:40
Downvoter,請解釋。 – Pupil 2014-10-29 15:05:13