We currently have 10 active users in our table (ID 6 is missing because we deleted it). Our goal is to update the last name of the user with ID 11. The UPDATE command is used to modify existing data in a table. When using PDO, it is critical to use prepared statements, preventing unauthorized parties from modifying the wrong data.
In the example above, we used the named parameters :last_name and :id. The
execute() method will securely insert these values into the SQL command and update the selected row.
WHERE condition, otherwise you will update every row in the table!