There is an array that I get from a site.com/?cpu=1,2&brand=2,3&ram=2,3 type link with the $ _GET method
array(3) { ["cpu"]=> string(3) "1,2" ["brand"]=> string(3) "2,3" ["ram"]=> string(3) "2,3" } How can I glue the following query from this array? PS Probably I have a wrong vision of making a request, if somewhere the logic of the request was wrong, please correct it.
SELECT * FROM table WHERE slug = cpu AND name = 1 OR slug = cpu AND name = 2 WHERE slug = brand AND name = 2 OR slug = brand AND name = 3 WHERE slug = ram AND name = 2 OR slug = ram AND name = 3 I tried to do something like this, but apparently I have the wrong idea about the implementation.
foreach($request->all() as $name => $value) { $valuesArray = explode(',', $value); foreach($valuesArray as $row) { $sql[] = 'WHERE ' . $name . '=' . $row; } } PS I make a dynamic filter that returns the position of the query which is generated through $ _GET