Home arrow PHP arrow 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.

  1. Adding More Methods to the Controller Class of an MVC-Based Framework
  2. Review: the initial definition of the user controller class
  3. Creating new users and updating existing ones
  4. The full definition of the controller class
By: Alejandro Gervasio
Rating: starstarstarstarstar / 1
June 30, 2010

print this article



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!

>>> More PHP Articles          >>> More By Alejandro Gervasio

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates


Dev Shed Tutorial Topics: