laravel 數據模型方法php
做用:提供了數據庫操做的方法laravel
<?php namespace App; use Illuminate\Database\Eloquent\Model; class Type extends Model { //聲明表 protected $table = "type"; //自動更新時間 public $timestamps = true; //type表 須要有 created 和 updatetime 字段 }
增:數據庫
Model::insert(array)app
Model::insertGetId(array)spa
$ob->saveblog
foreach($arr as $k=->$v)get
刪:it
Model:where()->delete()io
table()table
where()
改:
where()
Model:where()->update(array())
$ob = Xxx::where()->first()
$ob -> 字段名 = 值;
...
$ob ->save();
table()
查:
table()
select()
where()
groupBy()
orderBy()
limit()
offset()
join()
leftjoin()
rightjoin()
distinct()
union()
get()
first()
count()
paginate()
$cols->appends()->links()