I have a query of the form SELECT * FROM products WHERE 'id'= $id, 'name' = $name' ; finds nothing if one of the variables is undefined (null).
How to correctly construct a query with variables provided in the value of null, so that the choice works only where there is no null. So that if $ name is not known, then lines with $ id are output. If both parameters are known, then all rows.
In reality, I need a query with 5 parameters, so I want the condition here to be the query, not the if. And the default values don't suit me either (unless there is an ALL value).
(id=$id or $id is null) and (name=$name or $name is null)- Mike