PHP
  Home arrow PHP arrow Building a CodeIgniter Custom Library with Method Chaining
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Forums Sitemap 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
PHP

Building a CodeIgniter Custom Library with Method Chaining
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 1
    2009-11-11


    Table of Contents:
  • Building a CodeIgniter Custom Library with Method Chaining
  • Defining the CodeIgniter custom library's first methods
  • Extending the functionality of the AbstractModel class
  • Fetching, inserting and updating database records

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Building a CodeIgniter Custom Library with Method Chaining
    (Page 1 of 4 )

    Welcome to the seventh part of a 12-part series on the technique of method chaining in PHP 5. In this part, I will demonstrate how method chaining can be used to develop some core methods of a custom library for CodeIgniter.

    In case you haven’t explored it in depth yet, method chaining is a useful programming methodology that permits you to build highly modular and compact APIs when using the object-oriented paradigm. This isn’t a proprietary feature of a specific programming language; however, it’s possible to implement it with relative ease in PHP 5.

    Thus, if you’re a PHP developer who wants to master the basics of creating chainable methods while defining your own classes, then this series of articles might be the material that you’re looking for. In it you’ll find numerous examples that will show you how to apply the method chaining approach to building real-world applications.

    Now that you’re well aware of the goal of these tutorials, it’s time to reexamine the topics that were treated in the previous article. In that part of the series I completed the development of a simple, useful MySQL abstraction class that had the ability to perform typical retrieval queries by means of a few basic chainable methods.

    Despite the rather simplistic logic implemented by the methods of this class, this particular example hopefully demonstrated how to use chainable methods for building a PHP program that can be used under “real conditions.”

    However, as I said at the beginning of this series, my goal here is to illustrate how this approach can be implemented for creating applications that can be used in production environments. So, with that premise in mind, in the next few lines I’m going to show you in a step-by-step fashion how to build a custom library for the popular CodeIgniter framework. The library will allow you to perform the most common database operations without having to create multiple models.

    Also, some of the methods that will be implemented within this application will rely partially on the great DataMapper library developed by Simon Stenhouse at http://stensi.com/datamapper, so I’d like to give the corresponding credit to him. Of course, if you need to get a full-featured ORM for CodeIgniter, I recommend you to give the library a try here (http://stensi.com/datamapper/pages/download.html). It’s really worthwhile.

    Finally, a word of warning is in order here before you continue reading: the library will be pretty huge, with plenty of modular chainable methods, so I suggest that you arm yourself with patience and willpower to understand how each method is going to work.

    Having clarified those points, it’s time to start building this custom library for CodeIgniter by using the functionality provided by method chaining. Let’s do it right now!



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

       

    PHP ARTICLES

    - Working with Reflected Properties with the R...
    - The Iterator, Countable and ArrayAccess SPL ...
    - Implementing the Data Mapper Design Pattern ...
    - Defining an Abstract Class with Restrictive ...
    - The Reflection API: Working with Reflected M...
    - Using Restrictive Constructors in PHP 5
    - Getting Information on a Reflected Class wit...
    - Introducing the Reflection API in PHP 5
    - Swift Mailer's Batchsend Method and Other Fe...
    - Embedding Attachments into Email Messages wi...
    - Dynamically Attaching Files with Swift Mailer
    - Using Different Paths for Attachments with S...
    - Handling Attachments and Sending HTML Email ...
    - Sending Blind Carbon Copies with Swift Mailer
    - Using Swift Mailer's Cc MIME Header


    Code Analysis Tools
    Enterprise code analysis tools that deliver quality and reliable code

     


     


    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek