我想在笨的陣列來檢查多個值...如何在codeigniter中檢查數組中的多個值?
我只知道這個...
$vehicles = array('Car','Bike','Plane','Bus');
$this->db->where_in('Car,Bike', $vehicles);
請幫我... 在此先感謝...
我想在笨的陣列來檢查多個值...如何在codeigniter中檢查數組中的多個值?
我只知道這個...
$vehicles = array('Car','Bike','Plane','Bus');
$this->db->where_in('Car,Bike', $vehicles);
請幫我... 在此先感謝...
與https://www.codeigniter.com/userguide3/database/query_builder.html源一樣,where_in中的第一個參數應該是表列名稱。
根據您最後的評論:你可以用array_slice
功能得到第一陣列的兩個要素:
$vehicles = array('Car','Bike','Plane','Bus'); $slicedArray = array_slice($vehicles, 0, 2); $this->db->where_in('column_name', $slicedArray);
我不知道你這個問題,但我認爲你正在尋找這樣的:
$vehicles = array('Car','Bike','Plane','Bus');
$this->db->where_in('vehicle', $vehicles); //assuming vehicle is the name of a
//column in your database. Result will be:
// WHERE vehicle IN ('Car', 'Bike', 'Plane', 'Bus');
SIr,謝謝你的回答...但是,我想檢查汽車,車輛列中的自行車..我的意思是多個值...如何做到這一點? –
我認爲你正在尋找此代碼
$vehicles = array('car'=>'car','bike'=>'bike');
$this->db->where_in($vehicles);
謝謝 心心try.it工作
的可能的複製[通行證陣列到在笨的Active Record(http://stackoverflow.com/questions/13717555/pass-array-to-在codeigniter活動記錄) –