on-internet
← Community

WHERE clause containing status condition AND at least one column LIKE one of multiple search words using CodeIgniter's query builder [duplicate]

Stack Overflow ·

I have a table in my database named posts where I’d like to create search engine functionality. Here are the basic fields for this: table: `Posts` `post_id` (pk) `title` `keywords` `visible` // this is the critical point I have created also this method in my post_model: public function search() { $this->db->select('post_id, title, etc etc ...'); // separate the words $words = preg_split('/[\s]+/', htmlentities((trim($this->input->post('search'))))); // set fields that you wish to search $search_fields = array('title', 'keywords'); // build the query foreach ($words as $word) { foreach ($search

Comments

Sign in or sign up to comment and upvote.

No comments yet.