restore soft deleted item in database |
Hello,
i am using the ci Model Class with $useSoftDeletes = true. Now i want to implement a recycle bin to my application. Searching the deleted items works fine.. but i don't know how to restore these itemes? I tried to update($primaryKey,['deleted_at'=>null]) or an update with complete user data in hope that an update deletes the delete timestamp... But nothing worked. I searched in the documentation but there is nothing about restore.. just how to prevent deleting with soft_deletes I hope someone can help me solving this problem... best regards, Niklas
You should be able to restore a row by setting the deleted_at field to NULL. I wonder if the update was actually executed of if it was discarded because the data is null. Can you confirm what actual SQL query was executed?
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/ (03-22-2020, 08:31 AM)includebeer Wrote: You should be able to restore a row by setting the deleted_at field to NULL. I wonder if the update was actually executed of if it was discarded because the data is null. Can you confirm what actual SQL query was executed? I fixed it - my mistake was that i didn't add "deleted_at" to the allowed field array in my model |
Welcome Guest, Not a member yet? Register Sign In |