How To Generate Dynamic Similar Clause Alongside Parentheses Using Codeigniter Active Record?
If you lot desire to brand dynamic too custom LIKE clause using Codeigniter active record, next business office volition endure useful. For Example The release of tags too values is unknown. Arrays are created dynamically. This business office tin help you lot to attain what you lot desire to it. //To add together parentheses to a greater extent than or less the LIKE clauses business office make_like_conditions (array $fields, $search_text) { $likes = array(); foreach ($fields equally $field) { $likes[] = "$field LIKE '%$search_text%'"; } furnish '('.implode(' || ', $likes).')'; } business office do_something() { $search_fields = array( 'field_1', 'field_2', 'field_3', ); $search_text = "apple"; $like_conditions = $this->make_like_conditions($search_fields, $search_text); $query = $this->db->from('sometable')->where($like_conditions)-...