mardi 5 juillet 2016

How do you handle optional parameters in PHP PDO?


I have a MYSQL table with 5 fields, 2 of which can be null. I have to write PHP PDO for insert and update commands so that users can edit the table. For insert I used a switch statement with 3 cases to account for optional fields. I started writing update when I realized I would need 16 cases for all combinations of fields since all but the primary key can be updated. Is there a more efficient way to accomplish this?


Aucun commentaire:

Enregistrer un commentaire