- Laravel - Action URL
- Laravel - Dump Server
- Laravel - Pagination Customizations
- Laravel - Artisan Commands
- Laravel - Guest User Gates
- Understanding Release Process
- Laravel - Hashing
- Laravel - Encryption
- Laravel - Artisan Console
- Laravel - Authorization
- Laravel - Authentication
- Laravel - CSRF Protection
- Laravel - Contracts
- Laravel - Facades
- Laravel - Event Handling
- Laravel - Error Handling
- Laravel - Ajax
- Laravel - Sending Email
- Laravel - File Uploading
- Laravel - Validation
- Laravel - Session
- Laravel - Localization
- Laravel - Forms
- Laravel - Errors & Logging
- Laravel - Working With Database
- Laravel - Redirections
- Laravel - Blade Templates
- Laravel - Views
- Laravel - Response
- Laravel - Cookie
- Laravel - Request
- Laravel - Controllers
- Laravel - Namespaces
- Laravel - Middleware
- Laravel - Routing
- Laravel - Configuration
- Laravel - Application Structure
- Laravel - Installation
- Laravel - Overview
- Laravel - Home
Laravel Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Laravel - Working With Database
Laravel has made processing with database very easy. Laravel currently supports following 4 databases −
MySQL
Postgres
SQLite
SQL Server
The query to the database can be fired using raw SQL, the fluent query builder, and the Eloquent ORM. To understand the all CRUD (Create, Read, Update, Delete) operations with Laravel, we will use simple student management system.
Connecting to Database
Configure the database in config/database.php file and create the college database with structure in MySQL as shown in the following table.
Database: College
Table: student
Column Name | Column Datatype | Extra |
---|---|---|
Id | int(11) | Primary key | Auto increment |
Name | varchar(25) |
We will see how to add, delete, update and retrieve records from database using Laravel in student table.
Sr.No. | Record & Description |
---|---|
1 | We can insert the record using the DB facade with insert method. |
2 | After configuring the database, we can retrieve the records using the DB facade with select method. |
3 | We can update the records using the DB facade with update method. |
4 | We can delete the record using the DB facade with the delete method. |