【发布时间】:2019-01-17 09:24:23
【问题描述】:
我已将所有 where 子句保存在一个变量中,我正在尝试在 laravel 查询中加入该变量,但它不起作用。这是我的代码
$where .= "";
$where .= '->where("product_details.title", '.$request->title.')';
$where .= '->where("product_details.id", '.$request->id.')';
$results = DB::table('product_details').'$where'.->get();
如何在查询中使用变量?
【问题讨论】:
-
您的查询是动态的吗?如果不是,你为什么要这样做?另外,您是否尝试过运行它?那么你得到了什么错误?
-
是的,它是动态的,我得到的错误是“语法错误,意外'->' (T_OBJECT_OPERATOR)”