/**
  * Logs in the user using the given username and password in the model.
  * @return boolean whether login is successful
  */
 public function signup()
 {
     $user = Band::model()->findByAttributes(array('name_band' => $this->name));
     //create model in the models folder
     if ($user != null) {
         // user already exist
         $this->addError('name', 'This name already exists');
         return false;
     } else {
         if ($this->name == null) {
             $this->addError('name', 'Name cannot be blank');
             return false;
         } else {
             if ($this->password == null) {
                 $this->addError('password', 'Password cannot be blank');
                 return false;
             } else {
                 if ($this->genre == null) {
                     $this->addError('genre', 'Genre cannot be blank');
                     return false;
                 }
             }
         }
     }
     $_band = new Band();
     $_band->page_band = $this->page;
     $_band->name_band = $this->name;
     $_band->password_band = $this->password;
     $_band->genre_band = $this->genre;
     $_band->email_band = $this->email;
     $_band->desc_band = $this->desc;
     $_band->save();
     return true;
 }
 /**
  * Authenticates a user.
  * The example implementation makes sure if the username and password
  * are both 'demo'.
  * In practical applications, this should be changed to authenticate
  * against some persistent user identity storage (e.g. database).
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     $user = Band::model()->findByAttributes(array('name_band' => $this->username));
     //create model in the models folder
     if ($user === null) {
         // No user found!
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if ($user->password_band !== $this->password) {
             // Invalid password!
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             // Okay!
             $this->errorCode = self::ERROR_NONE;
         }
     }
     return !$this->errorCode;
 }
 public function actionNewGeneral()
 {
     $user = Yii::app()->user->name;
     $resultData = new Band();
     $resultData = Band::model()->findAllBySql('SELECT id_band FROM tband WHERE name_band = "' . $user . '"');
     $rider = new Rider();
     $rider->name_rider = "";
     $rider->id_band = $resultData[0]->id_band;
     $rider->save();
     $this->redirect(array("general", array('id' => $rider->id_rider)));
 }