PHP code example of etubaro / cakephp-eager-loader

1. Go to this page and download the library: Download etubaro/cakephp-eager-loader library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

etubaro / cakephp-eager-loader example snippets


CakePlugin::load('EagerLoader');

$Comment->find('first', [
	'contain' => [
		'Article.User.Profile',
		'User.Profile',
	]
]);

$Comment->Behaviors->disable('EagerLoader');
$Comment->Behaviors->load('Containable');
$Comment->contain('Article');
$result = $Comment->find('first');

$actsAs = [
	'EagerLoader.EagerLoader', // Requires higher priority than Containable
	'Containable'
]
` php
class Post extends AppModel {
    public $actsAs = array('EagerLoader.EagerLoader');
}