laravel 數據模型方法


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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM