正如標題所說,我可以把'%'
在笨如何在codeigniter中設置通配符類似查詢的通配符選項?
$this->db->like('title', 'match', 'before');
// Produces: WHERE title LIKE '%match'
的類似查詢關聯數組
$array = array('title' => $match, 'page1' => $match, 'page2' => $match);
$this->db->like($array);
// WHERE title LIKE '%match%' AND page1 LIKE '%match%' AND page2 LIKE '%match%'
更多的澄清我的模型具有的功能在我發送一個陣列,可處理大部分選擇查詢參數來檢索結果
function getTableData($table='', $fields='', $like=array(),$like1=array())
{
//Check For like statement
if(is_array($like) and count($like)>0)
$this->db->like($like);
if(is_array($like1) and count($like1)>0)
$this->db->or_like($like1);
//Check For Fields
if($fields!='')
$this->db->select($fields);
else
$this->db->select();
$result = $this->db->get();
//pr($result->result());
return $result;
}
這是我的通用函數,所以在發送參數或mod ifying函數如何使用通配符放置第三個參數,默認'both'
按原樣運行。
與第三參數i控制%
載置,但是當我使用一個關聯陣列如何可以實現通配符笨放置。 我如何在關聯數組中使用它,以適用於不同的列。是否有可能?我知道我可以使用自定義查詢,目前我正在使用它。任何幫助提前致謝。
我知道我可以像使用很多次是有可能assoc命令陣列我的通用功能 –