Làm cách nào để tạo xóa mềm?

Điều khó chịu khi xóa dữ liệu khỏi cơ sở dữ liệu là nó sẽ biến mất vĩnh viễn. Chúng tôi thậm chí không thể xem dữ liệu để xem liệu chúng tôi có cần nó hay không vì nó đã biến mất. Nếu chúng tôi cần lấy lại dữ liệu, giải pháp duy nhất của chúng tôi là khôi phục bản sao lưu và hy vọng chúng tôi có bản sao lưu ngay trước khi nó bị xóa để giảm thiểu tổn thất

Rất may, Laravel cung cấp một tính năng tích hợp sẵn cho phép chúng ta gắn cờ các hàng cơ sở dữ liệu là đã xóa mà không thực sự xóa chúng khỏi cơ sở dữ liệu. Bài viết/video này thảo luận về cách sử dụng Soft Deletes trong Laravel

Tại sao chúng ta nên sử dụng xóa mềm?

Như chúng ta đã thảo luận trong phần “Dừng xóa dữ liệu”, khi chúng ta

class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
6 một hàng từ cơ sở dữ liệu, nó sẽ biến mất vĩnh viễn mà không cần trải qua quá trình khôi phục cơ sở dữ liệu đầy đủ có thể gây đau đớn. Xóa mềm dữ liệu cho phép chúng tôi dễ dàng xem và khôi phục dữ liệu với công việc tối thiểu và có thể tiết kiệm rất nhiều thời gian khi dữ liệu vô tình bị xóa

Laravel cung cấp hỗ trợ xóa mềm bằng cách sử dụng đặc điểm

class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
7

di cư

Phần đầu tiên của quy trình chúng ta cần giải quyết là thiết lập các bảng cơ sở dữ liệu để có cột

class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
8

Thêm các cột xóa mềm vào một bảng mới

Hãy bắt đầu bằng cách tạo một mô hình mới để theo dõi một

class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
9 trong một ứng dụng quản lý dự án. Chúng tôi sẽ tạo mô hình và di chuyển trong một bước để chúng tôi có thể lười biếng nhất có thể

$ php artisan make:model -m Project
Model created successfully.
Created Migration: 2020_05_02_012758_create_projects_table

Khi chúng tôi mở di chuyển mới được tạo, chúng tôi sẽ thêm các dòng sau vào chức năng

$ php artisan migrate
Migrating: 2020_05_02_012758_create_projects_table
Migrated:  2020_05_02_012758_create_projects_table [0.01 seconds]
0 của chúng tôi

$table->string['name'];
$table->softDeletes[];

Nó trông như thế này

class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}

Lệnh gọi hàm

$ php artisan migrate
Migrating: 2020_05_02_012758_create_projects_table
Migrated:  2020_05_02_012758_create_projects_table [0.01 seconds]
1 là thứ thiết lập bảng để cho phép đặc điểm
class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
8 hoạt động. Không có nó, chúng tôi sẽ gặp lỗi truy vấn

Bây giờ chúng tôi sẽ chạy di chuyển

$ php artisan migrate
Migrating: 2020_05_02_012758_create_projects_table
Migrated:  2020_05_02_012758_create_projects_table [0.01 seconds]

Hãy xem bảng trông như thế nào bên trong MySQL

class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
1

Như chúng ta có thể thấy có một cột

$ php artisan migrate
Migrating: 2020_05_02_012758_create_projects_table
Migrated:  2020_05_02_012758_create_projects_table [0.01 seconds]
3 trong định nghĩa bảng. Đây là những gì cuộc gọi
$ php artisan migrate
Migrating: 2020_05_02_012758_create_projects_table
Migrated:  2020_05_02_012758_create_projects_table [0.01 seconds]
1 được thêm vào bảng và đặc điểm của
class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
8 sẽ sử dụng để theo dõi nếu hàng đã bị xóa

Thêm các cột xóa mềm vào một bảng hiện có

Hãy xem cách chúng ta có thể thêm các cột xóa mềm vào một bảng hiện có. Chúng tôi sẽ tạo một di chuyển mới bằng cách sử dụng lệnh

$ php artisan migrate
Migrating: 2020_05_02_012758_create_projects_table
Migrated:  2020_05_02_012758_create_projects_table [0.01 seconds]
6 để thêm các cột vào bảng
$ php artisan migrate
Migrating: 2020_05_02_012758_create_projects_table
Migrated:  2020_05_02_012758_create_projects_table [0.01 seconds]
7 vì ngoài hộp, Laravel không có cột này trên bảng
$ php artisan migrate
Migrating: 2020_05_02_012758_create_projects_table
Migrated:  2020_05_02_012758_create_projects_table [0.01 seconds]
7

class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
8

Tiếp theo, chúng ta sẽ thay đổi quá trình di chuyển để nó vừa thêm các cột trong hàm

$ php artisan migrate
Migrating: 2020_05_02_012758_create_projects_table
Migrated:  2020_05_02_012758_create_projects_table [0.01 seconds]
0 [
$ php artisan migrate
Migrating: 2020_05_02_012758_create_projects_table
Migrated:  2020_05_02_012758_create_projects_table [0.01 seconds]
1] vừa xóa chúng trong hàm
class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
11 [
class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
12]

class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
3

Một lần nữa, chúng tôi sẽ chạy di chuyển

class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
4

Thiết lập mô hình để sử dụng xóa mềm

Bây giờ chúng ta đã thiết lập các bảng cơ sở dữ liệu, chúng ta có thể bắt đầu làm việc với các mô hình đã xóa mềm trong mã của mình. Bước đầu tiên là thêm đặc điểm

class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
7 vào các mô hình. Dưới đây là một mô hình ví dụ mà chúng tôi đã thiết lập nó để sử dụng logic
class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
8

Điều quan trọng cần lưu ý là mặc dù chúng tôi đã thêm cột

class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
8 vào mô hình của mình nhưng Laravel không tự động sử dụng nó cho đến khi chúng tôi thêm đặc điểm, vì vậy chúng tôi vẫn sẽ xóa dữ liệu mà không có nó.

class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
8

Xóa một mô hình

Bây giờ mọi thứ đã được thiết lập, hãy kiểm tra xem điều gì sẽ xảy ra

Trước tiên, chúng tôi sẽ sử dụng tinker để tạo một

class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
9 mới

class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
0

Khi chúng tôi kiểm tra cơ sở dữ liệu, chúng tôi có thể thấy rằng nó đã được duy trì trong cơ sở dữ liệu và cột

$ php artisan migrate
Migrating: 2020_05_02_012758_create_projects_table
Migrated:  2020_05_02_012758_create_projects_table [0.01 seconds]
3 được đặt thành
class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
18 cho biết rằng nó chưa bị xóa

$table->string['name'];
$table->softDeletes[];
0

Bây giờ chúng ta sẽ xóa mô hình

$table->string['name'];
$table->softDeletes[];
1

Và quay lại MySQL, chúng ta có thể thấy

$ php artisan migrate
Migrating: 2020_05_02_012758_create_projects_table
Migrated:  2020_05_02_012758_create_projects_table [0.01 seconds]
3 không còn là
class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
18, điều này cho biết nó đã bị xóa

$table->string['name'];
$table->softDeletes[];
2

Khôi phục một mô hình

Nếu chúng ta vô tình xóa mô hình, Laravel giúp dễ dàng khôi phục bản ghi bằng hàm

class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
81

$table->string['name'];
$table->softDeletes[];
3
$table->string['name'];
$table->softDeletes[];
0

Xóa một mô hình

Giả sử bạn gặp trường hợp ai đó vô tình nhập thông tin và chúng tôi cần xóa bản ghi khỏi cơ sở dữ liệu chứ không chỉ đánh dấu nó là đã xóa.

class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
8 cung cấp chức năng
class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
83 sẽ làm việc đó

$table->string['name'];
$table->softDeletes[];
5
$table->string['name'];
$table->softDeletes[];
6

Tìm một mô hình đã xóa

Điều gì xảy ra khi chúng ta xóa một mô hình và cần tìm nó sau?

Đầu tiên, hãy thiết lập một

class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
9 mới và xóa nhẹ nó

$table->string['name'];
$table->softDeletes[];
7

Khi chúng tôi cố gắng sử dụng

class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
85, chúng tôi sẽ nhận được một
class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
86 vì đặc điểm của
class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
8 đang lọc chúng ra

$table->string['name'];
$table->softDeletes[];
8

Để giải quyết vấn đề này, chúng ta cần gọi hàm

class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
88 trước khi gọi hàm
class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
85

$table->string['name'];
$table->softDeletes[];
9

Tìm một mô hình đã xóa trong một mối quan hệ

Một phần khác trong mã của chúng ta mà chúng ta cần chú ý là khi chúng ta có một mô hình xác định mối quan hệ Eloquent với các mô hình

class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
8

Thông thường, chúng tôi sẽ xác định mối quan hệ của chúng tôi như vậy

class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
0

Nếu

class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
31 được liên kết với
class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
9 này bị xóa mềm và chúng tôi cố gắng truy cập nó thông qua mối quan hệ này, hàm sẽ trả về
class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
18

class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
1

Giải pháp cho vấn đề này một lần nữa là sử dụng hàm

class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
88 để nó trả về kết quả

class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
2____03

Xem các mô hình bị xóa từ bộ điều khiển

Một trong những phần khó chịu về đặc điểm xóa mềm là nếu người dùng cố gắng truy cập trang để tìm tài nguyên đã bị xóa, họ sẽ nhận được lỗi 404 và không phải thứ gì hữu ích như thông báo cho họ biết mục đã bị xóa. Để giải quyết vấn đề này, chúng ta có thể thêm một cuộc gọi tới

class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
88 vào định nghĩa tuyến đường của mình

class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
4

Thêm
class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
36

Ngoài ra, một trong những điều chúng tôi muốn làm cũng là theo dõi ai đã xóa mô hình. Điều này rất hữu ích vì sau đó chúng tôi không chỉ có thể cho mọi người biết thời điểm một thực thể bị xóa mà còn có thể cho họ biết ai đã làm việc đó. Nó giúp bạn dễ dàng tìm ra lý do tại sao nó bị xóa nếu không phải vậy

Chúng tôi làm điều này bằng cách thêm một cột

class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
36 và sau đó chúng tôi tạo hàm
class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
38 của riêng mình để đặt cả hai cột
$ php artisan migrate
Migrating: 2020_05_02_012758_create_projects_table
Migrated:  2020_05_02_012758_create_projects_table [0.01 seconds]
3 và
class CreateProjectsTable extends Migration
{
    public function up[]
    {
        Schema::create['projects', function [Blueprint $table] {
            $table->id[];
            $table->timestamps[];
            $table->string['name'];
            $table->softDeletes[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['projects'];
    }
}
36 thành các giá trị chính xác và lưu kết quả

Khi nào bạn nên xóa mềm?

Thông thường, nếu đang sử dụng cơ sở dữ liệu quan hệ, thì bạn có thể có các ràng buộc về khóa ngoại khiến bạn không thể xóa các hàng để thực thi tính toàn vẹn của dữ liệu . Bạn không muốn tham chiếu đến EmployeID123 trong một bảng khác khi nó không còn tồn tại.

Sự khác biệt giữa xóa và xóa mềm là gì?

Xóa cứng và mềm . A “hard” delete is when rows are deleted using DELETE FROM table WHERE ... Xóa “mềm” là khi các hàng bị xóa bằng bảng CẬP NHẬT SET delete_at = now[] WHERE.

Làm cách nào để xóa mềm trong MySQL?

Một cách phổ biến để thực hiện xóa mềm là thêm một trường cho biết dữ liệu đã bị xóa hay chưa . Lệnh SQL này sẽ xóa vĩnh viễn sản phẩm có id=1 khỏi bảng trong cơ sở dữ liệu. Lưu ý rằng chúng tôi đã thêm một trường mới có tên là đã xóa. Trường này sẽ chứa các giá trị 0 hoặc 1.

Xóa mềm trong Outlook là gì?

Khi người dùng xóa một mục trong hộp thư [chẳng hạn như email, liên hệ, cuộc hẹn trên lịch hoặc tác vụ], mục đó sẽ được chuyển đến thư mục Mục có thể khôi phục và vào thư mục con có tên "Xóa". Điều này được gọi là xóa mềm

Chủ Đề