Problem to get stdClass Object values |
[eluser]freelife[/eluser]
Code: Array ( [0] => stdClass Object ( [userId] => 1 [userLogin] => bb [userEmail] => [email protected] [userPassword] => 598418f18486e41f90415326b71f11a5 [userName] => Boris [userAge] => 0 [userGender] => 0 [userMobile] => 0000000 [userPhone] => 0000000 [userRegIp] => 0 [userProfession] => IT [userType] => user [userStatus] => active ) ) When i check user for presence in DB, it always return 1 unique row, because userEmail is unique i use this code: Code: $user = $this->GetUsers(array('userEmail' => $options['userEmail'] , 'userPassword' => $this->_salt($options['userPassword']))); Question is, how to get values from stdClass Object I use this and it is working Code: $user[0]->userLogin; But possible somehow Code: $user->userLogin; Thank you for help, i'm newbie in this theme.
[eluser]Edmundas KondraĊĦovas[/eluser]
You should have a separate function for retrieving one specific entry from the database. For example, get_user_by_id(ID) or get_user(params). In this case if it's always going to be only one single row, you can first assign the return value of the function to a temporary variable. Code: $tmp = $this->GetUsers(array('userEmail' => $options['userEmail'] , 'userPassword' => $this->_salt($options['userPassword']))); And then assign it to a variable that you are going to use. Code: $user = $tmp[0];
|
Welcome Guest, Not a member yet? Register Sign In |