Blogger Information
Blog 37
fans 0
comment 1
visits 29824
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
laravel查询构造器请求与cookie-2019-11-07
H先生
Original
680 people have browsed it

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);
    }
}
?>

运行实例 »

点击 "运行实例" 按钮查看在线实例

1.png




分页



实例

<?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);
    }
}
?>

运行实例 »

点击 "运行实例" 按钮查看在线实例

1.png









Correction status:qualified

Teacher's comments:完成的很好, 图文结合, 继续
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post