my sql command within codeigniter is not working -


i tested function doesn't work , no query result produced. what's wrong im newbie. there ar alternatives? im trying create mini search engine. in advance.

function search($terms) {   $sql = "select * products            name '%$terms%'              or image '%$terms%'              or code '%$terms'");     $query = $this->db->query($sql, array($terms, $terms));     return $query->result(); } 

to bind query data passed function, have following:

$sql = "select * products            name ?              or image ?             or code ?";  $this->db->query($sql, array($terms,$terms,$terms)); 

also in our posted code, remove parenthesis string $sql , binding 2 values, when query requires 3

try this:

$sql = "select * products            name ?              or image ?             or code ?"; $this->db->like('name', $terms); $this->db->like('image', $terms); $this->db->like('code', $terms); $query=$this->db->get(); 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -