laravel中model查询数据

   public function selectById(Request $request){
         $id = $request->get("id");
         $result = Test::find($id)->toArray();
        // 查询满足条件的一批数据
         $result1 = Test::where("id",">","11806943")->where("name","like","%"."马"."%")->get();
         
        // 查询满足条件的第一条数据
        $result1 = Test::where("id",">","11806943")->where("name","like","%"."马"."%")->first();
        foreach ($result1 as $key1 => $value1){
            echo $value1;
        }
    }

 

posted @ 2022-01-13 19:48  动力起点  阅读(432)  评论(0编辑  收藏  举报