|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
MySQL & deleting files on filesystem (Triggers?)
I have a table containing the filenames of images on the filesystem, if the record is deleted I want to delete the associated file. How would I go about this? (is this possible with Triggers? although these are not available in MySQL until v5.1)
The alternative is to store the files in the db, thus eliminating the need to delete files on the filesystem Cheers, Ben |
|
#2
|
||||
|
||||
|
How're you deleting records? If through a custom web app, just add some code to delete files upon row deletion. Another option is to set up a cron job that periodically compares the file system to the files listed in the database and deletes any that aren't found in the db. I don't know that a trigger would work here. I'm not very familiar with triggers, but I would have thought they'd allow you to perform other database operations automatically (but not filesystem operations).
__________________
Please don't PM me asking for solutions outside the scope of a thread. Keeping all responses in a thread stands to help others who come along later, which is after all what this forum's all about. |
|
#3
|
|||
|
|||
|
Quote:
I'm deleting records via a foreign key constraint - hence the web app doesn't know deleting a single record will result in a cascade. Thus I cannot simply add code to the web app to handle the deletion of files. Ben |
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > MySQL & deleting files on filesystem (Triggers?) |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|