Coder101 0 Denunciar post Postado Janeiro 7, 2008 Bom dia galera, estou com problemas para setar valores nesta classes: Alguem poderia me ajudar? class user extends MySQL { private $login; private $f_name; private $l_name; private $job_pos; private $role; private $team_leader; private $manager; private $employee_opt; private $company_id; private $flag_access; private $flag_control; private $password; private $query_login; public function setLogin($login){ $this->login = $login; } public function setPassword($password){ $this->password = $password; } public function getLogin(){ return $this->login; } public function getPassword(){ return $this->password; } public function register($user_id,$f_name,$l_name,$job_pos,$role,$employee_opt,$team_leader,$manager,$company_id,$flag_access,$flag_control){ $values = null; $query = null; $query2=null; $Characters = 'abncdxyvwzABCDLZYWZ0123456789'; $max = strlen($Characters)-1; $Password = null; for($i=0; $i < 8; $i++) { $Password .= $Characters{mt_rand(0, $max)}; } $values = "'".$user_id.",".$Password."'"; switch ($job_pos){ case 0 : //Insertion of the user in the login table $query = $this->myAdd("login","User_Id_FK,Password",$values); if ($this->myNumrows($query)<>0){ $values = "'".$user_id.",".$f_name.",".$l_name.",".$job_pos.",".$role.",".$employee_opt.",".$company_id.",".'1'.",".$flag_control."'"; //Insert of the user in the user table $query2 = $this->myAdd("user","User_Id_Pk,First_Name,Last_Name,JobPos_Id_FK, Role_Id_FK, Company_Id,Flag_access,CheckBox_opt",$values); } if($this->myNumrows($query2)<>0){ return true; } else{ return false; } break; case 1 : //Insertion of the user in the login table $query = $this->myAdd("login","User_Id_FK,Password",$values); if ($this->myNumrows($query)<>0){ $values = "'".$user_id.",".$f_name.",".$l_name.",".$job_pos.",".$role.",".$employee_opt.",".$company_id.",".'1'.",".$flag_control."'"; //Insert of the user in the user table $query2 = $this->myAdd("user","User_Id_Pk,First_Name,Last_Name,JobPos_Id_FK, Role_Id_FK, Company_Id,Flag_access,CheckBox_opt",$values); } elseif($this->myNumrows($query2)<>0){ return true; } else{ return false; } break; case 2 : //Insertion of the user in the login table $query = $this->myAdd("login","User_Id_FK,Password",$values); if ($this->myNumrows($query)<>0){ $values = "'".$user_id.",".$f_name.",".$l_name.",".$job_pos.",".$role.",".$employee_opt.",".$manager.",".$company_id.",".$flag_access.",".$flag_control."'"; //Insert of the user in the user table $query2 = $this->myAdd("user","User_Id_Pk,First_Name,Last_Name,JobPos_Id_FK, Role_Id_FK,Manager_Id,Company_Id,Flag_access,CheckBox_opt",$values); } elseif($this->myNumrows($query2)<>0){ return true; } else{ return false; } break; case 3: //Insertion of the user in the login table $query = $this->myAdd("login","User_Id_FK,Password",$values); if ($this->myNumrows($query)<>0){ $values = "'".$user_id.",".$f_name.",".$l_name.",".$job_pos.",".$role.",".$employee_opt.",".$team_leader.",".$manager.",".$company_id.",".$flag_access.",".$flag_control."'"; //Insert of the user in the user table $query2 = $this->myAdd("user","User_Id_Pk,First_Name,Last_Name,JobPos_Id_FK, Role_Id_FK,Team_Leader,Manager_Id,Company_Id,Flag_access,CheckBox_opt",$values); } elseif($this->myNumrows($query2)<>0){ return true; } else{ return "nada"; } break; } $this->myDisconnect(); return "nao funfou"; } function login(){ $where = "User_Id_FK='".$this->setLogin."'"; $this->myConnect(); $query = "SELECT User_Id_FK,Password FROM login WHERE ".$where; //select login from login table $result = $this->myExe($query); //verify if exists user if (mysql_num_rows($result) <> 0) { //verify if password is correct if (mysql_result($result,0,"Password")==$this->setPassword) { //select flag to know if it is the first time or no $where1 = "User_Id_PK='".$this->setLogin."'"; $sql = "SELECT Flag_access FROM user WHERE ".$where1; $query_fg_access = $this->myExe($sql); switch(mysql_result($query_fg_access,0,"Flag_access")) { case "default" : return "error fg_access"; break; case "0" : return 0; break; case "1" : return 1; break; } } else { $this->myDisconnect(); return "entrou 1"; } } else { $this->myDisconnect(); return "entrou 2"; } return "entrou 2"; } } test.login.php include_once('classes/iuser.class.php'); $login = new user(); $login->setLogin('gui'); $login->setPassword('gui'); $login->login(); Este script nao funciona Compartilhar este post Link para o post Compartilhar em outros sites
Beraldo 864 Denunciar post Postado Janeiro 7, 2008 $where = "User_Id_FK='".$this->setLogin."'"; setLogin é um método. A variável é login. Logo: $this->login Compartilhar este post Link para o post Compartilhar em outros sites
Coder101 0 Denunciar post Postado Janeiro 7, 2008 sim, ja retirei, porem esta variavel me retorna um valor nulo Compartilhar este post Link para o post Compartilhar em outros sites
Alexsandro XPT 0 Denunciar post Postado Janeiro 7, 2008 Uhm esta é a legitima classe Model de uma table banco de dados? $where = "User_Id_FK='".$this->setLogin."'"; setLogin é um método. A variável é login. Logo: $this->login Compartilhar este post Link para o post Compartilhar em outros sites