HomePHP Adding More Methods to the Controller Class of an MVC-Based Framework
Adding More Methods to the Controller Class of an MVC-Based Framework
In this eleventh part of the series, I expand the initial functionality of the user controller class defined previously by adding two simple methods to it. These allow it to create new users in the associated MySQL table.
If you're a PHP coder who wants to learn how to use the Model-View-Controller design pattern to develop an extensible framework in a few simple steps, then you've come to the right place. This series of articles guides you through the construction of a stack of reusable components, which can be put to work together easily under the schema imposed by this architectural pattern.
And now that you've been introduced to the goal of this series, it's time to review the topics that were discussed in the last tutorial. In that part of the series I started building a basic MySQL-driven application, which used some of the classes that comprise this sample framework to fetch data from a table that stored some user-related records.
The class that performed this retrieval process was a simple controller, which used the functionality of its associated model for accessing the referenced MySQL table. However, it must be said that this controller class in its current state is very limited, since it currently can use only its "index()" method to fetch the aforementioned database records.
So, what's the next step that must be taken toward making the controller a bit more functional? Well, since its model already has the required logic to perform CRUD operations against the selected table, in the next few lines I'm going to add to the controller a couple of methods that will allow it to insert and update database rows in a simple fashion.
Now, it's time to get rid of the preliminaries and continue demonstrating with some functional code samples how to use this MVC-based framework for developing a simple database-driven web application. Let's get going!