I am using DB facade and select method to run raw SQL queries with bindings. Just need to know can we do have multiple parameters with the same name in the query and replace that by providing only 1 binding with parameter name.
e.g.
$sql = "SELECT students.id, students.name FROM students
where students.student_id = :student_id
where added_on = ( SELECT MAX( added_on ) AS newdate
FROM students WHERE student_id = :student_id)"
return DB::select($sql, [
'student_id' => 1
]);
note: it might possible that I do not have to use student_id twice in this query. It just an example. The purpose is to know if we can achieve this.
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2rW0bEo
via IFTTT
Aucun commentaire:
Enregistrer un commentaire