There are two ways to perform database operations in Laravel. one is to use the static method of the \ DB appearance object to directly execute SQL queries, another method is to use the static method of the Model class (in fact, it is also the
Recent small series in learning the world's most bull frame –laravel. In fact, learning framework is the idea of learning the framework! I would like to record in my blog Some of my experience in the Laravel study, Welcome to my other GitHub blog
One, selects retrieve all rows in the table
$users = db::table (' users ')->get ();
foreach ($users as $user)
{
var_dump ($user->name);
}
retrieving a single row from a table
$user = db::table (' users ')->where (' name ', ' John ')->first
1. IntroductionThe database query builder provides a convenient and smooth interface for creating and running database queries. The query builder can be used to perform most database operations in an application and work on all supported database
Laravel PHP Web Development FrameworkLaravel is a simple, elegant PHP Web development Framework (PHP Web framework). It frees you from the messy code of noodles, and it helps you build a perfect web app, and every line of code can be concise and
This article mainly introduces the Laravel framework database CURD operations, coherent operations, and Chain Operations Summary. This article contains a large number of common database operations methods. For more information, see Laravel.
I.
Laravel framework database CURD operations, consistent operation summary, laravelcurd
I. Selects
Retrieve all rows in a tableCopy codeThe Code is as follows:$ Users = DB: table ('users')-> get ();Foreach ($ users as $ user){Var_dump ($ user-> name );
First, selectsRetrieving all rows in a tableThe code is as follows:$users = db::table (' users ')->get ();foreach ($users as $user){Var_dump ($user->name);}Retrieving a single row from a tableThe code is as follows:$user = db::table (' users
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.