我的Active Record(DB_active_rec.php
類)改變了,我將此代碼添加到忽略where_in
條件,如果數值數組是空的。所以現在適用於我。 我添加的代碼之間// @開頭和// @結束
/**
* Where_in
*
* Called by where_in, where_in_or, where_not_in, where_not_in_or
*
* @param string The field to search
* @param array The values searched on
* @param boolean If the statement would be IN or NOT IN
* @param string
* @return object
*/
protected function _where_in($key = NULL, $values = NULL, $not = FALSE, $type = 'AND ')
{
if ($key === NULL OR $values === NULL)
{
return;
}
//@begin
// Ignore where_in condition if values array's empty
if(is_array($values) && empty($values))
{
return $this;
}
//@end
// More method stuff
不要害怕,只顯示你的查詢花花公子 –
@echo_Me:他*是*。 '$ this-> db-> where_in('p.brand_id',$ brands);'將'WHERE IN'追加到查詢中。這個問題很清楚。 –
你確定$品牌是一個數組嗎?如果不是,它會失敗...檢查這個[link](http://ellislab.com/codeigniter/user-guide/database/active_record.html) – iubema