search

Home  >  Q&A  >  body text

Does tp5 come with soft deletion problem?

As long as use SoftDelete; is written in the model, the data cannot be queried in pages. How is this going? ? ? ? ?

Waiting online........................


KevinQKevinQ2485 days ago1591

reply all(2)I'll reply

  • PHP中文网

    PHP中文网2018-02-02 13:56:23

    Soft deletion and real deletion

    $user = model('User');
    $user::destroy(1);   // 软删除$user::destroy(1,true);   // 真实删除$user->delete();     // 软删除$user->delete(true);  // 真实删除

    By default, the query data does not include soft deleted data. If it needs to be included, query like this:

    $user = model('User');$data = $user::withTrashed()->select();

    If you only query soft deleted data, use this:

    $user = model('User');$data = $user::onlyTrashed()->select();


    reply
    1
  • Cancelreply