I did something like this to merge two tables into one, using the Zend_Auth.
$this->auth = Zend_Auth::getInstance();
$authAdapter = new Zend_Auth_Adapter_DbTable($this->db);
$authAdapter->setTableName('users');
$authAdapter->setIdentityColumn('username');
$authAdapter->setCredentialColumn('password');
$authAdapter->setCredentialTreatment('md5(?)');
// Set the input credential values to authenticate against
$authAdapter->setIdentity($params['username']);
$authAdapter->setCredential($params['password']);
// try and authenticate the user
$result = $this->auth->authenticate($authAdapter);
if ($result->isValid()) {
// success
$data = $authAdapter->getResultRowObject();
// returns object array, id, username, password, aclgroup
// get this users details
$dat = getUserData($data->id);
// returns db array, first name, last name, e-mail, subscription exp date,
last online, tracking token, etc
// merge data from Auth object
$dat['username'] = $data->username;
$dat['aclgroup'] = $data->accessgroup;
// save modified auth data
$this->auth->getStorage()->write((object) $dat );
} else {
// invalid login, show error
}
Maybe it will help you some.
Terre
_____
From: Eric Haskins [mailto:[email protected]]
Sent: Thursday, January 15, 2009 12:51 AM
To: [email protected]
Subject: [fw-general] Zend_Auth and a Join??
Hello can anyone tell me the best way to accomplish this? I am porting a
legacy app I maintain to use MVC. On the auth query I join a customer info
table to store some other info in the session.
// Login Attempt
$sql = "SELECT
*,
UNIX_TIMESTAMP(renew) AS renew_unix,
UNIX_TIMESTAMP(signup) AS signup_unix
FROM
`users`
LEFT JOIN `users_info` USING (userid)
WHERE
username = '".clean_string('username')."'
AND
passwd = '".md5(clean_string('passwd'))."'";
$res = $db->get_row($sql);
How can I port this for use Zend_Auth so the additional info is stored in
the Auth or should I just suck it up and combined users_info and users.
Thx for any ideas
Eric