The collected post has been deleted by the user, which means that the post table does not have this post, but the collection table still has data. I used the associated method to find out that it is empty. However, the result I want is to display "This post has been deleted." ”
php code:
$collect = db('collect')->where('user_id',session('user_data.id'))
- >alias('a')->join('content b','a.content_id=b.id')
->paginate(10);
Post table :
Collection list:
Do not delete physically, try to delete logically and modify the status.
Currently designed to try LEFT JOIN
db('collect')->where('user_id',session('user_data.id'))->alias('a ')->leftJoin('content b','a.content_id=b.id')->paginate(10);
This is a design issue. Logically speaking, users should not be allowed to delete database data.
Even if deleted, it only changes the status to deleted, and the real data still exists.
If you want to delete the data in the database, then when the user deletes this post, he must delete all the relevant data of this post.
So I still recommend you to change the status of the post. After deleting the post, another person can query the post and be prompted that the post has been deleted.
And you are the administrator, so when querying, there will be no errors due to data loss