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()