delete() destroy()删除数据的区别---ThinkPHP5(TP5)对数据库操作总结

1.删除 delete()  destroy()

T::where('id=1')->delete(1);

T::where('id','in',[2,3])->delete();

T::destroy('4,5');

Db::table('t')->delete(6);

Db::table('t')->delete([7,8]);

删除返回值:

delete()返回删除的条数,若一条没有删除则返回值为零

destroy()返回true/false  ,若删除不纯在的记录,返回值依旧为true

Db::table('t')->destroy([9,10]);报以下错误

method not exist:think\db\Query->destroy

T::delete(1); 报以下错误

Non-static method think\Model::delete() should not be called statically

你可能感兴趣的:(delete() destroy()删除数据的区别---ThinkPHP5(TP5)对数据库操作总结)