Bladephp: Now with 8+ codeigniter, php, and laravel project 8+ php project From $37/Month From Rs. 2499/Month

How to use Raw Expressions in Laravel 5

mysql laravel
How to use Raw Expressions in Laravel 5

One such cool feature us using raw queries in laravel. These expressions will be injected into the query as strings but this is really helpful when you want to use raw expressions like aggregate functions. The queries can be executed using DB::Raw method.

Let’s create a DB::Raw method in laravel 5

$users = DB::table('users')
      ->select(DB::raw('count(*) as parent_count'),
               DB::raw('sum(amount) as parent_amount'))


Html code work in comment box

Related Post