CakePHP View a Record - CakePHP

How to View a Record in CakePHP?

To view data of database, we first need to get maintain of a table the usage of the TableRegistry elegance. we can fetch the instance out of registry using get() approach. The get() technique will take the name of the database table as argument. Now, this new example is used to discover statistics from database using locate() approach. This method will go back all data from the requested table.

Instance

Make modifications within the config/routes.php report as shown inside the following code.

config/routes.php

Create a UsersController.php file at src/Controller/UsersController.php. replica the subsequent code in the controller document.

src/controller/UsersController.php

Create a directory customers at src/Template, ignore if already created, and below that directory create a View file referred to as index.ctp. replica the following code in that document.

src/Template/Users/index.ctp

Execute the above instance by touring the subsequent URL

http://localhost:85/CakePHP/customers

Output

Upon execution, the above URL will give you the subsequent output.

view a rec

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

CakePHP Topics