[eluser]MartÃn M.[/eluser]
Hi.
I'm using query bindings to gather data from a database. I have a really simple query:
Code:
$query = $this->db->query("SELECT * FROM table WHERE name LIKE '%?%'", $term);
Of course this doesn't work, since generates this query (note the quotes surrounding the search term):
Code:
SELECT * FROM table WHERE name LIKE '%'yaddayadda'%'
I fixed it this way:
Code:
$query = $this->db->query("SELECT * FROM table WHERE nombre LIKE ?", '%' . $term . '%')
It works, but it feels like it's not a very brilliant thing. Is this the way to go or I'm being really stupid?