Recursively delete files and folders from one MYSQL table? |
[eluser]Christophe28[/eluser]
Hello, I have a large MYSQL table with files and folders (in one table) The files having a parent_folder_id indicating the parent folder id in the same table. Imagine a user delete a folder with 3 files and 1 folder. The SQL would be something like: "DELETE FROM items WHERE parent_folder_id = $parent_folder_id"; Great, but the problem is that I don't know if the folder within the deleted folder also has files and maybe even more folders with files to delete and so on ... So I was thinking to write a script which go check if the folder has any more folders and if so, get the folder_id and check again in the table ... At the end I need one array with all the ids of the items (files and folders) to delete at once in the table. Something like: Code: // $items = array with ids of deleted items Thanks in advance! Christophe
[eluser]Christophe28[/eluser]
I have found this article on MySQL: http://dev.mysql.com/tech-resources/arti...-data.html Seems exactly what I need! :-) |
Welcome Guest, Not a member yet? Register Sign In |