Nothing in your query suggests that you actually need a raw query for this. Take a look at the query builder docs and update your code accordingly, particularly look at select, where and whereIn (for the array). Using a variable in your raw query like you are doing is dangerous and makes your application vulnerable to SQL injection
Jun 4, 2019
2
Level 1
Query to select data from database table and array
How can I select data with raw query from data that exists both in database table and an array?
For example I want to store to $sc the result of the following query. The variable $cs is an array which has data from previous query execution.
$sc = DB::select(DB::Raw("select table1.object from table1, today_date where today_date.today <= table1.expiry_date and today_date.today >= table1.start_date and table1.id = $cs"));
Please or to participate in this conversation.