所以遵循了所有的基本教程。我使用的是Zend 1.8,但是在使用Zend_Auth_DB的時候我總是收到這個異常。任何想法,表格中只有一行。Zend_Auth:數據庫表結構
Exception information:
Message: The supplied parameters to Zend_Auth_Adapter_DbTable failed to produce a valid sql statement, please check table and column names for validity.
Stack trace:
#0 C:\projects\BHAA_ZEND\library\Zend\Auth\Adapter\DbTable.php(306): Zend_Auth_Adapter_DbTable->_authenticateQuerySelect(Object(Zend_Db_Select))
#1 C:\projects\BHAA_ZEND\library\Zend\Auth.php(117): Zend_Auth_Adapter_DbTable->authenticate()
#2 C:\projects\BHAA_ZEND\application\controllers\LoginController.php(79): Zend_Auth->authenticate(Object(Zend_Auth_Adapter_DbTable))
#3 C:\projects\BHAA_ZEND\application\controllers\LoginController.php(38): LoginController->getAuthAdapter(Array)
#4 C:\projects\BHAA_ZEND\library\Zend\Controller\Action.php(512): LoginController->processAction()
#5 C:\projects\BHAA_ZEND\library\Zend\Controller\Dispatcher\Standard.php(288): Zend_Controller_Action->dispatch('processAction')
#6 C:\projects\BHAA_ZEND\library\Zend\Controller\Front.php(945): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#7 C:\projects\BHAA_ZEND\library\Zend\Application\Bootstrap\Bootstrap.php(77): Zend_Controller_Front->dispatch()
#8 C:\projects\BHAA_ZEND\library\Zend\Application.php(328): Zend_Application_Bootstrap_Bootstrap->run()
#9 C:\projects\BHAA_ZEND\public\index.php(33): Zend_Application->run()
#10 {main}
這裏是違規的代碼。
public function getAuthAdapter(array $params)
{
$dbAdapter = Zend_Db_Table::getDefaultAdapter();
$authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);
$authAdapter->setTableName('login')
->setIdentityColumn('username')
->setCredentialColumn('password');
//->setCredentialTreatment('MD5(?)');
// pass to the adapter the submitted username and password
$authAdapter->setIdentity($username)->setCredential($password);
$auth = Zend_Auth::getInstance();
$result = $auth->authenticate($authAdapter);
if ($result->isValid()) {
// success : store database row to auth's storage system
// (not the password though!)
$data = $authAdapter->getResultRowObject(null, 'password');
$auth->getStorage()->write($data);
//$this->_redirect('/');
return $this->_helper->redirector('index','index');
} else {
// failure: clear database row from session
$this->view->message = 'Login failed.';
return $this->render('index');
}
return $result;
}
您是否閱讀過Zend_Auth_Adapter_DbTable的文檔? - 是的,但我不確定它是否清除或混淆了我的理解。
你有一個到數據庫的有效連接嗎? - 是的,有一個工作CRUD應用程序與相同的數據庫配置。
你的用戶表的結構是什麼? -
你是否正確地向Zend_Auth_Adapter_DbTable的構造函數指定了標識和憑證列? - 見上面的代碼,我相信如此。
您是否還指定了您要驗證的用戶名/密碼? - 是的,有一個Zend表單提交這些變量。
什麼是導致錯誤的SQL查詢?我覺得這就是。
SELECT `isp_partners_view`.*, (CASE WHEN `password` = '*****' THEN 1 ELSE 0 END) AS `zend_auth_credential_match` FROM `isp_partners_view` WHERE (`username` = '*****')
你能發佈一些信息呢?你使用Zend_Auth_DB進行了哪些調用? – Breakthrough 2009-08-20 19:53:52
你有沒有解決這個錯誤?根源和解決方案是什麼? – 2009-12-31 19:24:28