I have a custom OOP query object with prepared statements that I use for MySQL queries. The problem is that I have a LIKE
statement that will not allow me to insert data using a prepared statement.
How can I escape the data in this scenario? Here's my code:
$search_q = !empty($search) ? "AND `title` LIKE '%?%'" : "";
$items = DB::fetch("SELECT `title` FROM `products` WHERE `active` = 1 $search_q;", array($start));