laravel使用ORM操作数据库
public function mode(){ //查询所有
$isok=Student::get(); 新增、 (1)
$isok=Student::create([
'name'=>'123','pwd'=>'123' ]);
(2)
$stu=new Student();
$stu->name="123";
$stu->pwd="ww";
$isok= $stu->save(); //修改 $isok= Student::where('pwd','=','56')->update([
'name'=>'123'
]);
删除 $isok=Student::where('pwd','=','56')->delete();
dd($isok); } //模型代码
namespace App;
use Illuminate\Database\Eloquent\Model;
class Student extends Model{ 指定表明
protected $table='test';
允许批量赋值的字段
protected $fillable=['name','pwd'];
}