This is a problem I solved a lot of times in different ways, but never could quite get an elegant solution for.
I have an SQL string which I want to build:
$sql = "UPDATE table";
$sql .= "SET";
$sql .= "sqlTableName = 'Y', column2 = value2";
now, based on
isset($_GET['value1'])
I want to add:
$sql .= "sqlTableName = 'Y',"
and based on
isset($_GET['value2'])
I want:
$sql .= "sqlTableName2 = 'Y',"
to be added.
If I put the comma before or after the string I run into trouble.
Now I know how to solve it but how to do this elegantly?