Reputation: 26567
I have a table of photos like this:
photo_id, photo_url, user_id
When I want to delete a photo, I need to delete the row in the table and the photo on the server. So to do this, I need to do 2 queries:
SELECT
query to return the photo's url and delete it with unlink()
DELETE
query to delete the row in the tableIs a simpler way to do this, perhaps using only one query?
Upvotes: 0
Views: 262
Reputation: 4492
Your way the best way to do this....How can it be simpler....
Also, if your photos use ids then you may just delete the row instead of selecting the query to return to the photos URL. then if this is successful proceed with deleting the thumbnail
Upvotes: 2