编辑用户个人资料后更新Zend_Auth_Storage [英] Updating Zend_Auth_Storage after edit users profile
问题描述
我有以下情况: 我已经用数据库表登录了用户,标准身份验证
I have following situation: I have loged user, standard authentication with DB table
$authAdapter = new Zend_Auth_Adapter_DbTable(Zend_Db_Table::getDefaultAdapter());
$authAdapter->setTableName('users');
$authAdapter->setIdentityColumn('user_name');
$authAdapter->setCredentialColumn('password');
用户编辑个人资料时,我将其保存到Db中,但是我还需要更新存储空间(使用标准的Zend_Auth_Storage_Session).有什么简单的方法怎么做?非常感谢.
When user edits his profile, I save it into Db, but I need to update also storage (using standard Zend_Auth_Storage_Session). Is there any easy way how to do it? Many thanks.
推荐答案
您最好的选择是不要使用Zend_Auth的存储空间来保存可能更改的信息-默认情况下,它仅保存身份(出于充分的理由).我可能会制作一个User类,该类包装了所有的Auth,ACL(可能还有配置文件)功能,这些功能使用静态的get_current()方法来加载隐藏在会话中的用户.这样可以避免您在将会话填充到会话中时遇到的所有一致性问题,并且在您确实需要提高性能的情况下,为您提供了一个实现缓存的单一点.
Your best bet would be to not use Zend_Auth's storage to hold information that's likely to change - by default it only holds the identity (for good reason). I'd probably make a User class that wrapped all the Auth, ACL (and probably profile) functionality that uses a static get_current() method to load the user stashed in the session. This bypasses all the consistency issues you run into when stuffing it into the session as well as giving you a single point from which to implement caching if/when you actually need the performance boost.
这篇关于编辑用户个人资料后更新Zend_Auth_Storage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!