select count('vehicules.id') from vehicules INNER JOIN (equipements, contenirs) ON (contenirs.vehicule_id = vehicules.id AND contenirs.equipement_id = equipements.id) WHERE(vehicules.KMActuel-contenirs.dernierKM > equipements.kilometrageMax);
這是我想要在Laravel中執行的程式碼。 我嘗試了以下程式碼:
$special = DB::select("SELECT COUNT('vehicules.id') FROM vehicules INNER JOIN (equipements, contenirs) ON (contenirs.vehicule_id = vehicules.id AND contenirs.equipement_id = equipements.id) WHERE(vehicules.KMActuel-contenirs.dernierKM > equipements.kilometrageMax)");
我在視圖中呼叫變量,然後出現了以下錯誤:
htmlspecialchars() expects parameter 1 to be string, array given (View: C:\laragon\www\GSMV\resources\views\dash.blade.php)
您不能在傳遞給常規的 Eloquent 方法的字串中執行表達式。您必須使用可以對應解析的原始表達式: