Home > PHP Framework > Laravel > body text

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

little bottle
Release: 2019-04-24 17:01:47
forward
7388 people have browsed it

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!

Related labels:
source:cnblogs.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template