Miscellaneous Code

  Home arrow Miscellaneous Code arrow Inserting Database Records with a Code...
MISCELLANEOUS CODE

Inserting Database Records with a CodeIgniter PHP Framework Model
By: Alejandros Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 3
    2009-09-02

    Table of Contents:
  • Inserting Database Records with a CodeIgniter PHP Framework Model
  • Review: fetching database rows with the generic model
  • Coding a method for inserting database records
  • The complete source code of the generic model class

  •  
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement

    Inserting Database Records with a CodeIgniter PHP Framework Model


    (Page 1 of 4 )

    Welcome to the fourth part of an eight-part series that shows you how to build a generic model for the CodeIgniter PHP framework. In this part of the series, I code a new method for the generic model class which allows you to insert new records into the specified database table, as well as update an existing one. Keep reading for the full details.

    It’s not surprising that the CodeIgniter PHP framework has a large community of users. It comes packaged with a number of valuable features that make it appealing to many web developers: excellent online documentation (quite possibly its strongest point) and a flat learning curve, a solid set of classes and helpers, and finally, it allows developers to create web applications by using the Model-View-Controller pattern.

    However, there’s one feature lacking in CodeIgniter that's a detriment to its unquestionable quality. At the time of writing this article, it doesn’t provide a native ORM model. Of course, this issue can be easily fixed by picking up well-trusted third-party libraries like Simon Stensi’s DataMapper or IgniterRecord, since both of them come equipped with enough functionality to handle not only basic CRUD operations, but the most common types of relations between database tables (one-to-one, one-to-many, many-to-many, etc.).

    Even so, it’s also possible to develop a customized generic model for CI that permits you to quickly build PHP applications in a truly painless fashion. That's tje goal of this series of articles. So, if you’re interested in learning how to accomplish this in a few simple steps, then don’t hesitate anymore; begin reading now!

    Naturally, if you already went through the previous articles, it’s probable that at this time you have an approximate idea of how to create a generic model for CodeIgniter. And I’m saying this simply because in the earlier tutorials, not only did I create the bare bones structure of this model, but I provided it with some basic functionality, including the ability for fetching records from a specified database table according to certain conditions.

    Nonetheless, this generic model needs to be enhanced even more. Thus, with that premise in mind, in this fourth chapter of the series, I’m going to add another method to it, which will be responsible for inserting new records into the associated database table, thus extending its current functionality.

    So, are you ready to learn how this whole new method for the generic model of CodeIgniter will be coded? Then let’s get started!

    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