Miscellaneous Code

  Home arrow Miscellaneous Code arrow Fetching Database Rows with a Model fo...
MISCELLANEOUS CODE

Fetching Database Rows with a Model for the CodeIgniter PHP Framework
By: Alejandros Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 5
    2009-08-26

    Table of Contents:
  • Fetching Database Rows with a Model for the CodeIgniter PHP Framework
  • Review: the current AbstractModel class
  • Implementing the fetch() method
  • The complete source code of the generic model class

  •  
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement

    Fetching Database Rows with a Model for the CodeIgniter PHP Framework


    (Page 1 of 4 )

    Welcome to the third part of a series that walks you through building a generic model for the CodeIgniter PHP framework. Comprised of seven tutorials, this series shows you in a step-by-step fashion how to create a useful abstract PHP class that will allow you to fetch, insert, update and delete rows in a specified database table very easily by using only a few child models.

    If you’re an enthusiast user of CodeIgniter PHP framework and want to learn how to develop a generic model class that lets you perform CRUD operations against your database tables without having to spend endless hours coding multiple and complex models, then look no further. You've come to the right place.

    And now that you’ve been introduced to the primary goal of this series, it’s time to refresh the topics that were discussed in the last article. During that specific tutorial, I added a couple of straightforward methods to the initial “AbstractModel” class for storing the data that the model will use for performing insert and update operations, and also for setting the validation rules that will be applied to this data. Indeed, the way that these methods were implemented was pretty simple, so in theory you shouldn’t have major problems understanding how they work.

    However, as I expressed in previous tutorials, the generic model class in its current state doesn’t include much functionality. Fortunately, this scenario is about to change. In the next few lines I’m going to incorporate a brand new method into it, which will be responsible for fetching database records according to certain given conditions.

    This method will be a huge improvement that will expand the functionality of the “AbstractModel” class, trust me. So, if you’re interested in learning how it will be coded, then don’t waste more time in preliminaries; start reading this third chapter of the series now!

    More Miscellaneous Code Articles
    More By Alejandros Gervasio

    blog comments powered by Disqus

    MISCELLANEOUS CODE ARTICLES

    - Creating a Web Page Controller with the HMVC...
    - Coding Controllers and Views for the HMVC De...
    - A Sample Web Application with the HMVC Desig...
    - Adding a Class to Parse Views to an HMVC Des...
    - Building a Model Class for the HMVC Design P...
    - Filtering Input Data and Generating HTML For...
    - The HMVC Design Pattern: Working with MySQL ...
    - Dispatching Requests to MVC Triads with the ...
    - Implementing the Hierarchical Model-View-Con...
    - A Web App Based on a Model for the CodeIgnit...
    - Completing a Model for the CodeIgniter PHP F...
    - Validating Input Data with the CodeIgniter P...
    - Deleting Database Records with the CodeIgnit...
    - Inserting Database Records with a CodeIgnite...
    - Fetching Database Rows with a Model for the ...

    Developer Shed Affiliates

     



    © 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap