Correction status:qualified
Teacher's comments:完成的很好, 图文结合, 继续
WHERE查询
<?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'); $res = DB::table('director')->where('tid','=',1)->first(); print_r($res); } } ?>
点击 "运行实例" 按钮查看在线实例
分页
<?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::table('director')->paginate(5); print_r($res); } } ?>
点击 "运行实例" 按钮查看在线实例