businessDb; //$coachInfo = BusinessCoach::model()->find('coach_name=:name and status=0', array(':name'=>$this->username)); $coachInfo = BusinessCoach::model()->find('coach_name=:name', array(':name'=>$this->username)); if(empty($coachInfo)){ //$this->errorCode=self::ERROR_USERNAME_INVALID; //return false; return 'not exist'; } else if ($coachInfo->status == 1) { return 'account is disabled'; } else if($coachInfo->password !== md5(sha1($this->password))){ $this->errorCode=self::ERROR_PASSWORD_INVALID; return false; } else if($coachInfo->school_id){ $school = $conn->createCommand("select * from school where school_id = '{$coachInfo->school_id}'")->queryRow(); if(!$school) return "SCHOOL_NOT_EXISTS"; if($school["status"] == 1) return "SCHOOL_DELETED"; } $this->errorCode=self::ERROR_NONE; //Coach::model()->updateByPk($userInfo['user_id'],array('login_time'=>time())); unset(Yii::app()->session['myDatebase']); Yii::app()->session['coachInfo'] = $coachInfo; Yii::app()->session['coachInfo']['default_subject_id'] = 3; return true; } /* public function authenticate() { $users=array( // username => password 'demo'=>'demo', 'admin'=>'admin', ); if(!isset($users[$this->username])) $this->errorCode=self::ERROR_USERNAME_INVALID; elseif($users[$this->username]!==$this->password) $this->errorCode=self::ERROR_PASSWORD_INVALID; else $this->errorCode=self::ERROR_NONE; return !$this->errorCode; } */ }