PDO update with conditional?
- by dmontain
I have a PDO mysql that updates 3 fields.
$update = $mypdo->prepare("UPDATE tablename SET field1=:field1,
field2=:field2,
field3=:field3
WHERE key=:key");
But I want field3 to be updated only when $update3 = true;
Is this possible to accomplish with a single query?
I could do it with 2 queries where I update field1 and field2 then check the boolean and update field3 if needed in a separate query. But hopefully there is a way to accomplish this in 1 query?