我试图在laravel中使用where语句,但作为回报,我得到了空值。

这是代码

$vehicles_make_id = $_POST['vehicles_make_id']; //getting "Audi"
$vehicles_name_trim = $_POST['vehicles_name_trim']; //getting "A3, 2.0T Premium Automatic"

$vehicles_name_trim_ar = explode(',', $vehicles_name_trim);

$model_name = $vehicles_name_trim_ar[0]; //getting "A3"
$model_trim = $vehicles_name_trim_ar[1]; //getting "2.0T Premium Automatic"

$vehicles_body_ar = array_filter(array_unique(Model::where('model_make_id', $vehicles_make_id)
                                                   ->where('model_name',    $model_name)
                                                   ->where('model_trim',    $model_trim)
                                                   ->lists('model_body')));

print_r(2.0T Premium Automatic);


我检查了该值,并且该值存在于数据库中,但得到的是空白数组

最佳答案

我认为您在哪里错了,是不是他们错过了'='。

$vehicles_body_ar = array_filter(array_unique(Model::where('model_make_id', '=', $vehicles_make_id)->where('model_name', '=', $model_name)->where('model_trim', '=',  $model_trim)->lists('model_body')));


最后查询检查

$queries = DB::getQueryLog();
$last_query = end($queries);
print_r($last_query);

关于php - 在laravel中哪里方法不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24954065/

10-11 07:18