laravel 数据模型方法

 laravel 数据模型方法

作用:提供了数据库操作的方法

<?php
namespace App;
use IlluminateDatabaseEloquentModel;

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

原文地址:https://www.cnblogs.com/chenliuxiao/p/9262520.html