1. 删除特定记录
        public function delete()
        {
            // 获取要删除的对象;关键字为16
            $Teacher = Teacher::get(16);
    
            // 删除对象
            $Teacher->delete();
            
            return '删除成功';
        }
  2. 批量删除;即使想删除的记录不存在,也不会抛出异常,系统只会提示删除的记录条数为0
        public function delete()
        {
            // 直接删除相关关键字记录;关键字为16
            if ($count = Teacher::destroy(16))
            {
                return '成功删除' . $count . '条数据';
            }
           
            return '删除失败';
        }

     

相关文章:

  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-19
  • 2021-11-29
  • 2021-09-07
相关资源
相似解决方案