为 Zend_Auth_Adapter_DbTable 添加条件
这似乎是一个愚蠢的问题,但在这段代码中,我将在哪里插入条件 'WHERE state=1'
public function loginByUsernameAndPassword($username, $password)
{
$this->_auth_adapter = new Zend_Auth_Adapter_DbTable( $this->getAdapter() );
$this->_auth_adapter->setTableName('zend_administration_user')
->setIdentityColumn('user_nm')
->setCredentialColumn('password')
->setCredentialTreatment('SHA1(CONCAT(?,salt))');
$this->_auth_adapter->setIdentity($username)
->setCredential($password);
$result = Zend_Auth::getInstance()->authenticate($this->_auth_adapter);
return $result->isValid();
}
This may seem like a silly question, but in this code, where would I insert the condition 'WHERE state=1'
public function loginByUsernameAndPassword($username, $password)
{
$this->_auth_adapter = new Zend_Auth_Adapter_DbTable( $this->getAdapter() );
$this->_auth_adapter->setTableName('zend_administration_user')
->setIdentityColumn('user_nm')
->setCredentialColumn('password')
->setCredentialTreatment('SHA1(CONCAT(?,salt))');
$this->_auth_adapter->setIdentity($username)
->setCredential($password);
$result = Zend_Auth::getInstance()->authenticate($this->_auth_adapter);
return $result->isValid();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
基于 在 zf 手册中的示例中,我想说您可以将
AND state=1
添加到 setCredentialTreatment() 方法中:Based on an example in the zf manual, I would say you could add
AND state=1
into your setCredentialTreatment() method:对于那些希望进入这篇文章的人。有更好的方法来验证发生身份验证的同一个表中的条件:
对于上面的示例:
来源:http://framework. zend.com/manual/1.12/en/zend.auth.adapter.dbtable.html
For those who hope into this post. There is better way to validate a condition within the same table where the authentication happens:
For the example above:
Source: http://framework.zend.com/manual/1.12/en/zend.auth.adapter.dbtable.html