zl程序教程

您现在的位置是:首页 >  其它

当前栏目

Laravel - 使用 DB facade 实现CURD

实现 laravel DB CURD Facade 使用
2023-09-14 08:57:23 时间
<?php

 

namespace App\Http\Controllers;

 

use Illuminate\Http\Request;

 

use Illuminate\Support\Facades\DB;

 

use App\Student;

 

class studentController extends Controller
{
   public function index()
   {
    #新增
    // DB::insert('insert into student(name,age) values(?,?)',['劫',15]);

 

    #修改
    // DB::update('update student set age=? where id=?',[66,'3']);

 

    #删除
    DB::delete('delete from student where id=?',[2]);

 

    #查询
    $students =  DB::select('select * from student');
 
   }
}