2012-06-10 91 views
0

我是ZendFramework中的新成員。我正在使用windowsXP和xampp.I準備使用ZendFramework構建一個小應用程序。但是我得到了下面的錯誤。使用ZendFramework構建應用程序

Fatal error: Uncaught exception 'Zend_Db_Table_Exception' with message 'No adapter found for Users' in E:\xampp\php\ZendFramework\library\Zend\Db\Table\Abstract.php:755 
Stack trace: 
#0 E:\xampp\php\ZendFramework\library\Zend\Db\Table\Abstract.php(739): Zend_Db_Table_Abstract->_setupDatabaseAdapter() 
#1 E:\xampp\php\ZendFramework\library\Zend\Db\Table\Abstract.php(268): Zend_Db_Table_Abstract->_setup() 
#2 E:\xampp\php\ZendFramework\library\Zend\Db\Table.php(77): Zend_Db_Table_Abstract->__construct(Array) 
#3 E:\xampp\htdocs\testproject\application\controllers\IndexController.php(7): Zend_Db_Table->__construct() 
#4 E:\xampp\php\ZendFramework\library\Zend\Controller\Action.php(516): IndexController->indexAction() 
#5 E:\xampp\php\ZendFramework\library\Zend\Controller\Dispatcher\Standard.php(295): Zend_Controller_Action->dispatch('indexAction') 
#6 E:\xampp\php\ZendFramework\library\Zend\Controller\Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_ in E:\xampp\php\ZendFramework\library\Zend\Db\Table\Abstract.php on line 755 

任何人都可以說什麼是解決方案?

感謝

[production] 
phpSettings.display_startup_errors = 0 
phpSettings.display_errors = 0 
includePaths.library = APPLICATION_PATH "/../library" 
bootstrap.path = APPLICATION_PATH "/Bootstrap.php" 
bootstrap.class = "Bootstrap" 
appnamespace = "Application" 
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" 
resources.frontController.params.displayExceptions = 0 

[staging : production] 

[testing : production] 
phpSettings.display_startup_errors = 1 
phpSettings.display_errors = 1 

[development : production] 
phpSettings.display_startup_errors = 1 
phpSettings.display_errors = 1 
resources.frontController.params.displayExceptions = 1 

這些的application.ini文件的內容。

<?php 

class IndexController extends Zend_Controller_Action 
{ 
    public function indexAction() 
    { 
     $users = new Users(); 
     $data = $users->fetchAll($users->select()); 
     $this->view->data = $data; 
    } 
} 

?> 

這些IndexController.php的內容文件

@RockyFord

你的意思的application.ini文件應低於喜歡?

[production] 
    phpSettings.display_startup_errors = 0 
    phpSettings.display_errors = 0 
    includePaths.library = APPLICATION_PATH "/../library" 
    bootstrap.path = APPLICATION_PATH "/Bootstrap.php" 
    bootstrap.class = "Bootstrap" 
    appnamespace = "Application" 
    resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" 
    resources.frontController.params.displayExceptions = 0 

    resources.db.adapter = "pdo_Mysql" //PDO is best option, other adapters are available. 
    resources.db.params.username = "your_username" 
    resources.db.params.password = "your_password" 
    resources.db.params.dbname = "your_database_name" 
    resources.db.isDefaultTableAdapter = true //this line is optional but recommended. 


    [staging : production] 

    [testing : production] 
    phpSettings.display_startup_errors = 1 
    phpSettings.display_errors = 1 

    [development : production] 
    phpSettings.display_startup_errors = 1 
    phpSettings.display_errors = 1 
    resources.frontController.params.displayExceptions = 1 
+0

你可以發佈你的application.ini嗎? (**沒有任何敏感信息,如密碼當然) –

+0

也許,也可以在'IndexController'中發佈實例化Zend_Db_Table對象的行。 –

+0

缺少Zend_Db_Table的數據庫配置? – opHASnoNAME

回答

2

假設您正在使用mysql,將這些行添加到生產部分的application.ini中。

resources.db.adapter = "pdo_Mysql" //PDO is best option, other adapters are available. 
resources.db.params.username = "your_username" 
resources.db.params.password = "your_password" 
resources.db.params.dbname = "your_database_name" 
resources.db.isDefaultTableAdapter = true //this line is optional but recommended. 
+0

@Michael Irey, 我是ZendFramework中的新成員。我聽不懂你的話。 – Foysal