[eluser]pickupman[/eluser]
You would want to chain ->like() if each of the criteria is required for a result.
Code:
$searchflds = array('Publications_Title','Date','Type','First_Name','Last_Name');
$this->db->select('Publication_ID,Main_Author, Other_SEI_Authors,Other_non_SEI_Authors,Publications_Title,Publications_Photo,Type,Date,First_Name,Last_Name');
$this->db->from('tbl_publications');
$this->db->join('tbl_staff','StaffID = Main_Author');
foreach ($search_str as $ss)
{
foreach ($searchflds as $fld){
$this->db->like($fld, $ss);
}
}
$this->db->orderby('Date','desc');
$query=$this->db->get();
If you want any match, use (you can chain or_like(). CI will add the OR when it needs it):
Code:
$searchflds = array('Publications_Title','Date','Type','First_Name','Last_Name');
$this->db->select('Publication_ID,Main_Author, Other_SEI_Authors,Other_non_SEI_Authors,Publications_Title,Publications_Photo,Type,Date,First_Name,Last_Name');
$this->db->from('tbl_publications');
$this->db->join('tbl_staff','StaffID = Main_Author');
foreach ($search_str as $ss)
{
foreach ($searchflds as $fld){
$this->db->or_like($fld, $ss);
}
}
$this->db->orderby('Date','desc');
$query=$this->db->get();
You want to consider creating a sub statement like:
Code:
$where ="WHERE (Publication_Title LIKE '%".$ss."%' OR Publication_Title LIKE '%".$ss."%') AND (Type LIKE '%".$ss."%' OR Type LIKE '%".$ss."%') AND (//next)";
$this->db->where($where);
Depend on your desired results, try each see what you get and check which way is faster.