I have the following code(Laravel 5.6 PHP 7.0):
$orders = DB::table('orders')
->selectRaw('?', ['id'])
->get();
In my imagination that code has to perform such sql:
SELECT `id` FROM orders
and has to return a result like:
array [
0 => {
"id": "1"
}
1 => {
"id": "2"
}
unfortunately it returns this:
array [
0 => {
"?": "id"
}
1 => {
"?": "id"
}
But if I run the following code everything works as I want:
$orders = DB::table('orders')
->selectRaw('id')
->get();
So, my questions are:
Why does the first code returns such a strange result?
How to bind a column?