我在变量中有一个查询,我想运行它:
$sql = "select id,
title,
parent_id
from (select * from categories
order by parent_cat_id, id) base,
(select @pv := '$category_id') tmp
where find_in_set(parent_cat_id, @pv) > 0
and @pv := concat(@pv, ',', id)";
如何将其作为查询运行?
答案 0 :(得分:0)
我能够使用DB::select
函数运行查询:
$categories = DB::select($sql);
dd($categories);