Welcome Guest, Not a member yet? Register   Sign In
restore soft deleted item in database
#1

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 Undecided

I hope someone can help me solving this problem...

best regards,
Niklas
Reply
#2

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! ***/
Reply
#3

(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 Undecided
Reply




Theme © iAndrew 2016 - Forum software by © MyBB