Home arrow PHP arrow An Object-Oriented Approach to Lazy and Eager Loading in PHP 5

An Object-Oriented Approach to Lazy and Eager Loading in PHP 5

Welcome to the second installment of a series that shows you how to implement lazy and eager loading in PHP 5. Through a strong hands-on approach, this series teaches you how to use these patterns in some typical scenarios. In this way, you'll grasp their underlying logic and learn quickly how to take advantage of their functionality to speed up your own PHP-based programs.

  1. An Object-Oriented Approach to Lazy and Eager Loading in PHP 5
  2. Review: eager loading in PHP 5
  3. Building a basic loader class
  4. Using the Loader class in a sample script
By: Alejandro Gervasio
Rating: starstarstarstarstar / 4
September 16, 2009

print this article



Learning how to apply the lazy and eager loading design patterns in PHP 5 can have a huge impact in the performance of your web-based applications, especially if they rely on objects that are used for interacting with one or multiple database tables. Therefore, if you're interested in learning the key concepts that surround the implementation of these powerful behavioral patterns, then don't hesitate anymore and start reading right now!

And now that you know what to expect from this set of articles, it's time to refresh the topics that were discussed in the previous one. To summarize, in that first part of the series I developed an example to demonstrate how to use eager loading pattern in conjunction with a sample class that stored information about some fictional users through its properties.

The example was comprised of a single script that included the class at the very beginning of its execution, and created an instance of this class, even when this instance wasn't specifically requested by the program. In programming jargon, this process is commonly known as eager inclusion of a class (or eager loading, naturally). When applied in a clever way, it can help make certain applications run faster.

However, the example that I just described above used a mixture of procedural and object-oriented code to perform the corresponding eager loading process, which isn't very efficient. Thus, in this second chapter of the series I'm going to modify this example by employing a strict object-oriented approach.

Now, let's leave the preliminaries behind us and continue learning more about the eager loading pattern in PHP 5. Let's get started!

>>> 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: