I have the following Laravel query, it does not appear to be returning the $abort and $pend variables as strings:
$abort = "Aborted";
$pend = "Pending";
$transactions = DB::table('callpay_transactions')
->select(DB::raw('SUBSTR(created,1,7) as YrMth') ,DB::raw('SUM(amount) as total_sales' ))
->where('status', '!=', $abort)
->where('status', '!=', $pend)
->groupBy(DB::raw('SUBSTR(created,1,7)'))
->toSql();
dd($transactions);
The return sql query is as follows
"select SUBSTR(created,1,7) as YrMth, SUM(amount) as total_sales from `callpay_transactions` where `status` != ? and `status` != ? group by SUBSTR(created,1,7)"
Any ideas as to why my $abort and $pend variables show as strings?
2
Answers
i thing that is because of prepared statment and ? also indicate a placeholder while using prepared statment in php.
instead of to sql if you us get you will see the result.
If you want to see the full output with your parameters in place, you can do the following:
That will replace the ? characters with their actual binding values from your query.