<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\DB;
class StudentController extends Controller
{
public function test1()
{
//查詢
/*$result = DB::SELECT('SELECT * FROM WEB_USER WHERE USERID = 1');
dd($result);*/
//插入
/*$bool = DB::insert('insert into web_user(name,age) values(?,?)',['sean',18]);
print_r($bool);*/
//更新
/*$bool = DB::insert('update web_user set age = ? where userid = ?',[18,1]);
print_r($bool);*/
$bool = DB::delete('delete from web_user where userid = 112');
var_dump($bool);
}
}
注意:一定要添加 use Illuminate\Support\Facades\DB;
dd()打印數組對象