join table with find in cake php code example
Example 1: join cakphp
'joins' => array(
array(
'table' => Environment::read('table_prefix') . 'image_type_languages',
'alias' => 'language',
'type' => 'INNER',
'conditions'=> array(
'ImageType.id = language.image_type_id',
'language.alias = \'' . $language . '\'',
)
),
),
Example 2: single or cakephp
$conditions = array(
'OR' => array(
array( 'MemberRole.school_id' => array()),
array( 'MemberRole.role_id' => $role),
);
);
'OR' => array(
array(
'MemberRole.school_id' => array(),
'MemberRole.role_id' => $role,
),
array(
'MemberRole.school_id' => array(),
'MemberRole.role_id' => Environment::read('role.register'),
),
array(
'MemberRole.school_id' => $school_id,
'MemberRole.role_id' => Environment::read('role.register'),
),
array(
'MemberRole.school_id' => $school_id,
'MemberRole.role_id' => $role
)
)