我试图在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);
我检查了数据库中存在的值,但我得到一个空白数组
答案 0 :(得分:1)
我认为你的错在哪里,不是他们错过了'='。
$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);