How to use where and or_where in ignited datatables with codeigniter -
it's not working @ ->or_where('text like',"%dog%")
. i'm using make json format view in datatable please me!
$this->datatables->select('id,name,text,profile_image_url') //ignited datatables ->unset_column('id') ->unset_column('profile_image_url') ->unset_column('name') ->unset_column('text') ->add_column('profile_image_url', '<img src="$1"/>', 'profile_image_url') ->add_column('name','$1','name') ->add_column('text','$1','text') ->where('text like',"%cat%") ->or_where('text like',"%dog%") ->from('posts'); echo $this->datatables->generate();
it's not working cause have invalide syntax, using ->where means comparing if column equal second parameter, use function syntax should be
$this->db->like('text', 'cat'); $this->db->like('text2', 'dog');
but if want control wildcard (%) placed, can use optional third argument. options 'before', 'after' , 'both' (which default).
$this->db->like('title', 'match', 'before'); // produces: title '%match' $this->db->like('title', 'match', 'after'); // produces: title 'match%' $this->db->like('title', 'match', 'both'); // produces: title '%match%' default
hope you
Comments
Post a Comment