I want to make a data filter feature using the MULTISELECT category where the data that appears is in accordance with the list of categories selected on the filter. So, I plan to loop the OR WHERE command according to the list of categories chosen by the user. OR WHERE has been successfully loop according to the number of categories chosen, but not for the ID. And show error like this "Array to string conversion"
What is the cause and what is the solution? Thank you
My Controller
$sort = $this->input->post('sort');
$category = $this->input->post("get_kategori_acara_css[]");
$interest = $this->input->post("get_interest_acara_css[]");
/* eksekusi library pagination ke model penampilan data */
if (!empty($sort) || !empty ($category) || !empty ($interest))
{
$this->data['list_acara'] = $this->Acara_model->get_filtered($sort, $category, $interest, $config['per_page'], $dari);
}
else
{
$this->data['list_acara'] = $this->Acara_model->get_all_arsip();
}
MY MODEL
public function get_filtered ($sort, $category, $interest) {
$this->db->join('kategori', 'acara.id_kategori = kategori.id_kategori');
$this->db->join('interest_acara ', 'acara.id_acara = interest_acara.id_acara', 'left');
$this->db->join('hits_acara ', 'acara.judul_seo = hits_acara.judul_seo', 'left');
$this->db->where('publish','Ya');
$this->db->group_by('acara.judul_seo');
if(!empty($sort AND empty($category) AND empty($interest)))
{
$this->db->order_by($sort, $this->order);
}
elseif(!empty($sort) AND !empty($category) AND empty($interest))
{
foreach ($category as $value) {
$this->db->or_where('acara.id_kategori', $value->id_kategori);
}
}
return $this->db->get($this->table)->result();
}