I have a little problem please if someone can help me =D, I will be very grateful. when searching for products for sale: it only pulls me to search for a single name or field, I want to search for example "asus tablet" two fields.
this is my code:
public static function getLike($p){
$sql = "select * from product inner join category on product.category_id=category.id_categoria where name like '%$p%' or marca like '%$p%' or modelo like '%$p%' or barcode like '%$p%' or description like '%$p%'";
$query = Executor::doit($sql);
return Model::many($query[0],new ProductData());
}
By passing the variables directly in the query you expose yourself to an SQL injection attack , you should consider using prepared statements that among other things help to avoid that.
That said, you can use CONCAT to be able to search multiple fields with a string like this:
In your case you can use the function
explode
to obtain all the words of your query and then concatenate them in the search in this way