I have to work off of another companys db and its not proper so I need some help. The users don't have a common table, instead they are divided into two tables one called 'hotel' and another called 'vendor'. The system requires a unified login so that all users use the same login form. Auth is handled on a separate table but once they auth the only info I have about them is their email and the fact that authentication passed(Authentication data is not associated with the user other than by their email). From here on out I can make the code how I want it. SOOO... To me the first step is to grab the basic user info for the session. PROBLEM: The users are in two separate tables and I dont know how to do this: If the user is not found in one table the get_user function will look in the other. Will this work?: public function get_user($email) {
Quick SQL question-SOLVED
9
I have to work off of another companys db and its not proper so I need some help. The users don't have a common table, instead they are divided into two tables one called 'hotel' and another called 'vendor'. The system requires a unified login so that all users use the same login form. Auth is handled on a separate table but once they auth the only info I have about them is their email and the fact that authentication passed(Authentication data is not associated with the user other than by their email). From here on out I can make the code how I want it. SOOO... To me the first step is to grab the basic user info for the session. PROBLEM: The users are in two separate tables and I dont know how to do this: If the user is not found in one table the get_user function will look in the other. Will this work?:
public function get_user($email) {
global $db;
$result=$db->query("SELECT * FROM hotel WHERE primaryEmail='$email'") or $result=$db->query("SELECT * FROM vendor WHERE primaryEmail='$email'");
$result_set=$db->fetch_array($result);
$this->user_id=$result_set['user_id'];
$this->email=$result_set['email'];
$this->user_name=$result_set['user_name'];
}
public function get_user($email) {
global $db;
$result=$db->query("SELECT * FROM hotel WHERE primaryEmail='$email'") or $result=$db->query("SELECT * FROM vendor WHERE primaryEmail='$email'");
$result_set=$db->fetch_array($result);
$this->user_id=$result_set['user_id'];
$this->email=$result_set['email'];
$this->user_name=$result_set['user_name'];
}
- Mkj
- [ 1 ] Thanks
- [1] reply
- PHPSpaZ
- KirkMcD
- [ 1 ] Thanks
- [2] replies
- PHPSpaZ
- [1] reply
- PHPSpaZ
Next Topics on Trending Feed
-
9