JoinableBehavior takes an array in the structure similar to that of ContainableBehavior and creates automatic joins between the listed models, keeping your code clean.
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
type
- Type of join to use. Default:LEFT
conditions
- Conditions to join on, iftrue
is used, conditions will be set automatically. Default:true
$this->User->find('all', array(
'joins' => array(
'Profile' => array(
'type' => 'RIGHT',
),
'Subscription' => array(
'conditions' => '`Subscription`.`id` = `User`.`subscription_id` AND `Subscription`.`active` = 1',
'SubscriptionPlan',
),
),
));