I have this query which returns the matching rows. I need to ignore the condition for which the variable is null ex. :
If $data[0] is null, it would become
$parameters = array ($data[1], $data[2]);
$result = pg_query_params(connect(), 'SELECT * FROM person WHERE surname= $1 and status=$2', $parameters);
If $data[0] and $data[2] are null, it would become:
$parameters = array ($data[1]);
$result = pg_query_params(connect(), 'SELECT * FROM person WHERE surname= $1', $parameters);
And so on ...
This is the current query:
$parameters = array ($data[0], $data[1], $data[2]);
$result = pg_query_params(connect(), 'SELECT * FROM person WHERE name = $1 and surname= $2 and status=$3', $parameters);
I read about coalesce() but don't know how to include the parameters $1, $2, $3.