search

Home  >  Q&A  >  body text

I have a problem writing on the forum. Can anyone please help me if you have time?

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:

雪梦晨、曦雪梦晨、曦1359 days ago972

reply all(2)I'll reply

  • 枫叶知秋

    枫叶知秋2021-04-07 17:56:29

    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);

    reply
    0
  • 查无此人

    查无此人2021-04-07 11:45:12

    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

    reply
    0
  • Cancelreply