JoinableBehavior
JoinableBehavior takes an array in the structure similar to that of ContainableBehavior and creates automatic joins between the listed models, keeping your code clean.
Installation
cd app
git submodule add https://github.com/tigrang/cakephp-joinable.git Plugin/Joinable
- Add
CakePlugin::load('Joinable')
inapp/Config/bootstrap.php
- Add
public $actsAs = array('Joinable.Joinable');
toAppModel
Options:
type
- Type of join to use. Default:LEFT
conditions
- Conditions to join on, iftrue
is used, conditions will be set automatically. Default:true
Usage:
$this->User->find('all', array(
'joins' => array(
'Profile' => array(
'type' => 'RIGHT',
),
'Subscription' => array(
'conditions' => '`Subscription`.`id` = `User`.`subscription_id` AND `Subscription`.`active` = 1',
'SubscriptionPlan',
),
),
));