Question Detail

How to use LIKE Query with Codeigniter ?


Thread Reply

Anonymous

- 1 years ago

You can use this query:

SELECT * FROM table WHERE field LIKE ?

And bind with %search% instead of search.

You should be aware that this query will be slow in MySQL. You might want to look at free-text search instead (Lucene, Sphinx, or MySQL's built-in free-text search functions).

Anonymous

- 1 years ago

$this->load->helper('url');    
        $this->load->helper('file');    
        $this->load->library('session');    

Anonymous

- 1 years ago

\"
\\r\\n$search_term=$this->input->post('textboxName');\\r\\n$search_term="%".$search_term."%";\\r\\n$sql="SELECT * FROM table WHERE field LIKE ? ";\\r\\n$query=$this->db->query($sql,array($search_term));\\r\\n$res=$query->result();<\\/code><\\/pre>\\r\\n\"