Zend Framework: How best to go about retrieving the first name of an authenticated user?

I can get the username by doing this:

public function indexAction() { $this->view->username = Zend_Auth::getInstance()->getIdentity(); }

"username" is the column in the table that validates the identity. "firstname" is also a column in that table. Does Zend_Auth only store the username? Or is there a way to access other columns from the user's row in the table?

-------------Problems Reply------------

So you're using a DbTable adapter, right. And are you retrieving the table row after authentication like so:


Then yes, the whole user-row is available. Just try!

From the manual:

In addition to the availability of the getIdentity() method upon the authentication result object, Zend_Auth_Adapter_DbTable also supports retrieving the table row upon authentication success:

// Print the identity
echo $result->getIdentity() . "\n\n";

// Print the result row

/* Output:

[id] => 1
[username] => my_username
[password] => my_password
[real_name] => My Real Name

Or see for yourself!

Category:sql Views:0 Time:2009-04-17

Related post

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.149 (s). 11 q(s)