I have troubles with using a parameter in a DB query and parameter binding in Laravel.
I get this error:
Error: "Column not found: 1054 Unknown column '3' in 'on clause'"
This is the part of a query:
->join('foo AS f1', function($join) use ($bar)
{
$join->on('f1.foo', '=', 'f2.foo')
->on('f1.bar', '=', $bar);
})
If I do this instead, it works:
->on('f1.bar', '=', DB::raw($bar));
What's the solution to this? I would like to use parameter binding for this as well of course. However, when I do:
->on('f1.bar', '=', ':bar', ['bar' => $bar]);
I get this:
ErrorException in Grammar.php line 196:
Array to string conversion