CakePHP Working with Database - CakePHP

How to work with Database using CakePHP?

Running with database in CakePHP could be very clean. we will apprehend the CRUD (Create, read, update, Delete) operations on this chapter. before we continue, we need to create the following users’ table within the database.

similarly, we additionally need to configure our database in config/app.php report.

Insert a Report

To insert a document in database, we first need to get hold of a table the usage of TableRegistry elegance. we are able to fetch the instance out of registry the usage of get() approach. The get() method will take the name of the database table as a controversy.

This new example is used to create new entity. Set essential values with the example of recent entity. we've to name the save() technique with TableRegistry elegance’s instance with the intention to insert new document in database.


Make changes in the config/routes.php report as shown inside the following software.


Create a UsersController.php record at src/Controller/UsersController.php. replica the following code in the controller record.


Create a listing customers at src/Template and below that directory create a View report called upload.ctp. replica the following code in that report.


Execute the above example through travelling the subsequent URL.



Upon execution, you may obtain the following output.

working with DB

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd Protection Status

CakePHP Topics