简体   繁体   中英

cakephp login with or condition

I have written code for alogin.

Everything is okay but I want to add 1 more condition in our login query user_type 2 and 3 should be login only in below query. Only user_type 2 is logging.

$adminUser = $this->User->find("first",


array("conditions"=>array("OR"=>array(array("User.auth_key"=>$username),array("User.email"=>$username)),"User.password"=>$password,"User.user_type"=>2),
 "fields"=>array("User.idx","User.auth_key","User.email","User.first_name","User.last_name","User.profile_pic","User.user_type","User.email_activate_status","User.status","User.email_activation_code") ));

Try this with proper format and proper condition.

$conditions = array('OR' => array("User.auth_key"=>$username,"User.email"=>$username,"User.password"=>$password,'User.user_type' => '2','User.user_type' => '3'));
$fields = array("User.idx","User.auth_key","User.email","User.first_name","User.last_name","User.profile_pic","User.user_type","User.email_activate_status","User.status","User.email_activation_code");
$adminUser = $this->User->find("first",array("conditions"=> $conditions, "fields"=> $fields));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM