本文整理汇总了PHP中Zend_Auth_Adapter_DbTable::setAmbiguityIdentity方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Auth_Adapter_DbTable::setAmbiguityIdentity方法的具体用法?PHP Zend_Auth_Adapter_DbTable::setAmbiguityIdentity怎么用?PHP Zend_Auth_Adapter_DbTable::setAmbiguityIdentity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Auth_Adapter_DbTable
的用法示例。
在下文中一共展示了Zend_Auth_Adapter_DbTable::setAmbiguityIdentity方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login
/**
* This method logs in the user
* Member login
* @author Kashif Irshad
* @param string $userName
* @param string $password in md5 encryption
* @return string return 'success' for successfully login and all other messages are error message
*/
public function login($userName, $password, $remember)
{
$userTable = new Application_Model_DbTable_User();
$authAdapter = new Zend_Auth_Adapter_DbTable(Zend_Db_Table::getDefaultAdapter());
$authAdapter->setTableName('users');
$authAdapter->setIdentityColumn('username');
$authAdapter->setCredentialColumn('password');
$authAdapter->setIdentity($userName);
$authAdapter->setCredential($password);
$authAdapter->setAmbiguityIdentity(true);
$auth = Zend_Auth::getInstance();
$auth->setStorage(new Zend_Auth_Storage_Session('user'));
$result = $auth->authenticate($authAdapter);
if ($result->isValid()) {
if ($remember > 0) {
$oneMinute = 60;
$oneHour = $oneMinute * 60;
$oneDay = $oneHour * 24;
$oneWeek = $oneDay * 7;
$oneMonth = $oneDay * 30;
Zend_Session::rememberMe($oneWeek);
}
return 'success';
} else {
$userRow = $userTable->fetchRow("username='{$userName}'");
if (isset($userRow)) {
return 'Invalid password';
} else {
return 'Invalid username or password';
}
}
}