DBDataObject Nubee
| From: | Don Fitzsimmons | Date: | Tue, 13 Jul 2004 00:00:46 +0000 |
| Subject: | DBDataObject Nubee | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-13669@lists.php.net to get a copy of this message | ||
I am using DB_DataObject for the first time and I am in love. As with any worthwhile, lasting relationship, I can see this one is going to require some serious commitment and patience. I am trying to use a method to execute a DBDO query and I want to be able to access the object that it returns but I don't quite get what this baby is returning. Here's my code;
The "factory" class:
class UserDBServices
{
function authenticate($userName, $userPass)
{
$user = new DataObjects_Users();
$user->password = $userPass;
$user->username = $userName;
$user->find();
//create a new User object upon successful login
if($user != null) {
$user->fetch();
return $user;}else{
$_SESSION['loginError'] = 'loginError';
header('location:'.LOGIN_FORM_VIEW);
exit;
}
}
}
The implementation:
$person = new UserDBServices();
$person->authenticate('joeuser', 'letmein');
echo $person->first_name;
echo $person->last_name;
This does not work the way I'm trying to use it here, but this is what I want it to do. Can anyone help me understand how to access the values that DBDO returns?
Thanks, Don