How to write MySql Query in laravel?
I will show a simple query in laravel where you can easily understand that how query works in laravel 4.
$limit = 5;
$value= Bank::where('isactive','=','yes')->where('money','>',0)->whereNotNull('account')->whereNull('credit')->take($limit)->orderBy('id', 'DESC')->get();
This query act like as query below
select * from Bank where money>0 amd account!=null and credit='' order by id desc limit 0,5.
This is the representation that how laravel query works i added here where condition with 3 different ways and limti and order by for this query
$limit = 5;
$value= Bank::where('isactive','=','yes')->where('money','>',0)->whereNotNull('account')->whereNull('credit')->take($limit)->orderBy('id', 'DESC')->get();
This query act like as query below
select * from Bank where money>0 amd account!=null and credit='' order by id desc limit 0,5.
This is the representation that how laravel query works i added here where condition with 3 different ways and limti and order by for this query
This query will work for both Database
MYSQL
MongoDB
Comments
Post a Comment