2010-11-11 18 views
0

,發現沒有合適的回答,我問你:在Zend Framework中的Zend_Db_Table :: getDefaultAdapter()serching後向上和向下的互聯網絡返回Null

我想實現一個getAuthAdapter(數組$形式)

private function getAuthAdapter(array $form) { 

    $authAdapter = new Zend_Auth_Adapter_DbTable(
    Zend_Db_Table::getDefaultAdapter(), 
    'user', 
    'email', 
    'password', 
    'MD5(?) AND hidden = "FALSE"'); 
    $authAdapter->setIdentity($form['email']) 
    ->setCredential($form['password']); 

    return $authAdapter; 
} 

要建立一個數據庫連接,我添加以下行到我的的application.ini

resources.db.adapter = "PDO_MYSQL" 
    resources.db.params.host = "localhost" 
    resources.db.params.username = web5 
    resources.db.params.password = ACv8vSdn 
    resources.db.params.dbname = usr_web5_1 
    resourses.db.isDefaultTableAdapter = true 

但是,試圖劇本後,我遇到以下錯誤:

Application error 
Exception information: 

Message: No database adapter present 
Stack trace: 

0 /usr/share/php/libzend-framework-php/Zend/Auth/Adapter/DbTable.php(140):  Zend_Auth_Adapter_DbTable->_setDbAdapter(NULL) 
1 /var/www/web5/html/application/controllers/LoginController.php(49): Zend_Auth_Adapter_DbTable->__construct(NULL, 'user', 'email', 'password', 'MD5(?) AND hidd...') 
2 /var/www/web5/html/application/controllers/LoginController.php(23): LoginController->getAuthAdapter(Array) 
3 /usr/share/php/libzend-framework-php/Zend/Controller/Action.php(513): LoginController->indexAction() 
4 /usr/share/php/libzend-framework-php/Zend/Controller/Dispatcher/Standard.php(295): Zend_Controller_Action->dispatch('indexAction') 
5 /usr/share/php/libzend-framework-php/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) 
6 /usr/share/php/libzend-framework-php/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch() 
7 /usr/share/php/libzend-framework-php/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run() 
8 /var/www/web5/html/public/index.php(26): Zend_Application->run() 
9 {main} 

Request Parameters: 

array (
    'controller' => 'login', 
    'action' => 'index', 
    'module' => 'default', 
    'email' => '[email protected]', 
    'password' => 'test', 
    'login' => 'Login', 
) 

回答

0

你可能要檢查你的引導程序和調試代碼,加載分貝。

+0

謝謝你的努力,但我已經想出了它自己。 你是對的,我的引導程序中有太多額外的代碼,這阻止了數據庫連接。 – 2010-11-17 22:13:16

+1

你正走在正確的道路上......學習的最佳方式就是自己動手。 – nuaavee 2010-11-17 23:25:51