Thursday, March 30, 2017

whereraw Vs DB::raw in Laravel

I am confused and really don't know how and where should I choose to use one from both ?

I read docs for both

https://laravel.com/docs/5.4/queries#where-clauses

And

https://laravel.com/docs/5.4/queries#raw-expressions

If I use query something like this its not working

DB::table('table_name')
->where('parent_id', $parent_id)
->whereRaw("date",">",$date)
->get();

But it works

DB::table('table_name')
->where('parent_id', $parent_id)
->where(DB::raw("date",">",$date))
->get();



via Jio Raja

Advertisement