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)
Model::insertGetId(array)
$ob->save
foreach($arr as $k=->$v)
刪:
Model:where()->delete()
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()