批改状态:不合格
老师批语:原因, 你应该知道
Home.php
<?phpnamespace App\Http\Controllers;use DB;class Home extends Controller{// 数据库查询public function get(){echo '<pre>';$res = DB::select('select * from users');print_r($res);}//数据库更新public function gxupdata(){$res = DB::update('update users set name="我知道,最好的语言:php25岁了" where id=1');var_dump($res);}//数据库新增public function xzupdata(){$res = DB::insert('insert users(`name`,`email`,`password`)values("mignzi","ad@s.com","aginogsg")');var_dump($res);}//删除数据public function delete(){$res = DB::delete("delete from users where id=5");var_dump($res);}}
<?phpuse Illuminate\Support\Facades\Route;/*|--------------------------------------------------------------------------| Web Routes|--------------------------------------------------------------------------|| Here is where you can register web routes for your application. These| routes are loaded by the RouteServiceProvider within a group which| contains the "web" middleware group. Now create something great!|*/Route::get('/', function () {return view('v');// echo date('Y-m-d h:i:s');});Route::get('/article/p/aaa', function () {// return view('v');echo date('Y-m-d h:i:s');});Route::get('/db','Home@get');Route::get('/dbgx','Home@gxupdata');Route::get('/dbxz','Home@zxupdata');Route::get('/dbxz','Home@delete');
新增
修改:
删除:
查询:
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号