首先要在开头use DB,然后:
$arr = DB::select("select id,sum(parents+1) as total_people from orders where game_id=6 and pay_status=1 and hotel_id=5");
接下来,我们程序里怎么获取到查询到的值呢?
查询到的是一个数组,但是里面的内容属于对象,我们要这么调用:
$arr[0]->total_people;
上一篇:使用laravel怎么查询最后执行的一条sql语句
下一篇:Laravel 怎么将数据表的数据导出并生成seeds种子文件