HomePHP 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.
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!