1.更新管理员登录帐号email
实例
<?php namespace App\Http\Controllers; use Illuminate\Support\Facades\DB; use Illuminate\Http\Request; class Dbtest extends Controller { public function index(){ /*{ $res = DB::table('admin')->get()->all(); foreach ($res as $item){ echo $item->id.'-'.$item->email.'<br>'; } echo '<pre>'; print_r($res);*/ // 更新 $res = DB::update('update admin set email="无缝" where id=1'); var_dump($res); } } ?>
运行实例 »
点击 "运行实例" 按钮查看在线实例
2.添加管理员帐号
实例
<?php namespace App\Http\Controllers; use Illuminate\Support\Facades\DB; use Illuminate\Http\Request; class Dbtest extends Controller { public function index(){ /*{ $res = DB::table('admin')->get()->all(); foreach ($res as $item){ echo $item->id.'-'.$item->email.'<br>'; } echo '<pre>'; print_r($res);*/ // 更新 // $res = DB::update('update admin set email="无缝1" where id=?',[1]); // 添加 $res = DB::insert('insert admin(`email`,`psword`)values("xiaomao@qq.com","12345")'); var_dump($res); } } ?>
运行实例 »
点击 "运行实例" 按钮查看在线实例
3.删除一个管理员帐号
实例
<?php namespace App\Http\Controllers; use Illuminate\Support\Facades\DB; use Illuminate\Http\Request; class Dbtest extends Controller { public function index(){ /*{ $res = DB::table('admin')->get()->all(); foreach ($res as $item){ echo $item->id.'-'.$item->email.'<br>'; } echo '<pre>'; print_r($res);*/ // 更新 // $res = DB::update('update admin set email="无缝1" where id=?',[1]); // 添加 // $res = DB::insert('insert admin(`email`,`psword`)values("xiaomao@qq.com","12345")'); // 删除 $res = DB::delete('delete from admin where id=:uid',['uid'=>2]); var_dump($res); } } ?>
运行实例 »
点击 "运行实例" 按钮查看在线实例
4.查询管理员帐号
实例
<?php namespace App\Http\Controllers; use Illuminate\Support\Facades\DB; use Illuminate\Http\Request; class Dbtest extends Controller { public function index(){ /*{ $res = DB::table('admin')->get()->all(); foreach ($res as $item){ echo $item->id.'-'.$item->email.'<br>'; } echo '<pre>'; print_r($res);*/ // 更新 // $res = DB::update('update admin set email="无缝1" where id=?',[1]); // 添加 // $res = DB::insert('insert admin(`email`,`psword`)values("xiaomao@qq.com","12345")'); // 删除 // $res = DB::delete('delete from admin where id=:uid',['uid'=>2]); // 查询 $res = DB::select('select * from admin'); print_r($res); } } ?>
运行实例 »
点击 "运行实例" 按钮查看在线实例