导入命名空间和DB
namespace App\Http\Controllers;
use Illuminate\Support\Facades\DB;
public function index(){
//新增
$isok= DB::table(‘test‘)->insert([
‘name‘=>‘123‘,‘pwd‘=>‘56‘
]);
//修改
$isok=DB::table(‘test‘)
->where(‘name‘,‘rr‘)
->update([
‘name‘=>‘sb‘,‘pwd‘=>‘sss‘
]);
//查询
$isok=DB::table(‘test‘)->get();
//删除
$isok=DB::table(‘test‘)->delete();
var_dump($isok);
}
原文:http://www.cnblogs.com/wlphp/p/7771442.html