cakephp 3.5 get all records code example

Example: single or cakephp

// ------------------------------------
// ------------ one OR --------------
// ------------------------------------
$conditions = array(
    'OR' => array(
        array( 'MemberRole.school_id' 	=> array()),
        array( 'MemberRole.role_id' 	=> $role),
    );
);

// ------------------------------------
// ------------ multiple OR --------------
// ------------------------------------
 '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
   )
 )

Tags:

Php Example