在Laravel,爲什麼我得到一個錯誤Laravel - 無效參數號:參數沒有被定義
無效的參數號:參數沒有被定義
我已經包括了所有參數。
當我直接在PHPMyAdmin上測試時,它工作正常。
代碼:
$results = \DB::select('SELECT client_id,
date_format(start_date,"%d/%m/%Y") as start_date,
date_format(end_date,"%d/%m/%Y") as end_date,
first_name, last_name, phone, postcode
FROM hire INNER JOIN client ON client.id = hire.client_id
where ((:sdate between start_date and end_date OR :edate between start_date and end_date) OR (:sdate <= start_date and end_date <= :edate)) AND car_id = :car_id', [
'sdate' => $start_date,
'edate' => $end_date,
'car_id' => $car_id
]
);
變量例如:
$start_date = $inputs['start_date']; //2015-10-27
$end_date = $inputs['end_date']; //2015-10-27
$car_id = $inputs['car_id']; //5
Czan你顯示瞭如何爲3個變量設置值? –
@MateoBarahona更新了我的問題。 –