Download the PHP package chinpei215/cakephp-eager-loader without Composer
On this page you can find all versions of the php package chinpei215/cakephp-eager-loader. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download chinpei215/cakephp-eager-loader
More information about chinpei215/cakephp-eager-loader
Files in chinpei215/cakephp-eager-loader
Package cakephp-eager-loader
Short Description CakePHP 2.x plugin to make it possible to eager load
License MIT
Homepage https://github.com/chinpei215/cakephp-eager-loader
Informations about the package cakephp-eager-loader
EagerLoader Plugin for CakePHP 2.x
An eager loading beahavior plugin for CakePHP 2.x which is highly compatible to the Containable behavior but generates better queries.
Requirements
- CakePHP 2.x
- PHP 5.3+
Installation
See the How to Install Plugins in the CakePHP documentation for general help.
-
Put the
EagerLoader
directory into your plugin directory or install the plugin with Composer from the directory where your composer.json file is located: -
Load the plugin in your app/Config/bootstrap.php file:
- And enable the behavior in your models or in your app/Model/AppModel.php:
`
Usage
EagerLoaderBehavior
has a high compatibility with ContainableBehavior
, but generates better queries.
In the above example, only 2 queries will be executed such as the following:
If using ContainableBehavior
, how many queries are executed? 10 or more?
Incompatibility problems
EagerLoaderBehavior
returns almost same results as ContainableBehavior
, however you might encounter incompatibility problems between the 2 behaviors.
For example EagerLoaderBehavior::contain()
is not implemented yet.
Then disabling EagerLoaderBehavior
on the fly, you can use ContainableBehavior::contain()
instead:
For your information, EagerLoaderBehavior
can be coexistent with ContainableBehavior
.
Using this way, you need not to call load('Containable')
in the above example.