I am new to laravel 4 and keep getting the same error trying to learn about some methods in DB class.
Call to undefined method Illuminate\Database\Query\Builder
I get same erros trying to use "->or_where", "->order_by".
another problem is parsing the dynamic methods:
->where_name("test")
turns into
`users` where `_name` = test)
but if i try to do
->wherename("test")
then everything is fine.
You're using an incorrect syntax for orWhere
and orderBy
.
This is the correct syntax for orWhere
:
DB::table('users')
->where('name', '=', 'John')
->orWhere(function($query)
{
$query->where('votes', '>', 100)
->where('title', '<>', 'Admin');
})
->get();
And this for orderBy
:
$users = DB::table('users')
->orderBy('name', 'desc')
->get();
Query Builder - Advanced Wheres - Laravel
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With