Home  >  Article  >  PHP Framework  >  DB::RAW() syntax usage example in Laravel framework

DB::RAW() syntax usage example in Laravel framework

little bottle
little bottleforward
2019-04-24 17:01:477182browse

The main content of this article introduces the DB::RAW() syntax and attaches the usage code. I hope interested friends can learn about it.

I encountered a problem in the project before. It was very inconvenient to use laravel's query constructor for complex sql queries. It was a headache to stitch together a long list of various query conditions; then I wanted to use the native sql statement to query, and then laravel's paginate() paging method cannot be used; at this time, the DB::raw() method comes in handy!

As shown in the picture:

Result:

The principle of this syntax is to query your The result set is treated as a temporary table, and then paging is performed using laravel's query builder syntax. I hope it will be helpful to you.

Related tutorials: laravel video tutorial

The above is the detailed content of DB::RAW() syntax usage example in Laravel framework. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete