0

I am new in ZendFramework. I am using windowsXP and xampp.I am tring to build a small application using ZendFramework.But I got the below errors.

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

Can anyone say what is the solution??

Thanks

[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

These are the content of application.ini file.

<?php

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

?>

These are the content of IndexController.php file

@RockyFord

Do you mean that application.ini file should like below??

    [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
5
  • Can you post your application.ini? (without any sensitive information like passwords of course) Commented Jun 10, 2012 at 13:49
  • And perhaps, also post the line in the IndexController where you instantiate the Zend_Db_Table object. Commented Jun 10, 2012 at 14:22
  • missing DB configuration for Zend_Db_Table ? Commented Jun 11, 2012 at 5:26
  • Can you connect to MySQL from the location where the app is running? (command line, phpMyAdmin, etc...). Also do you have the pdo extension loaded? Are you sure your mysql credentials are correct? Commented Jun 12, 2012 at 20:03
  • sorry it took so long, but yes that is the correct file. Just make you have setup a database in mysql before you try to connect to it. Commented Jun 17, 2012 at 6:20

1 Answer 1

2

assuming you are using mysql add these lines to your application.ini in the production section.

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.
Sign up to request clarification or add additional context in comments.

1 Comment

@Michael Irey, I am new in ZendFramework. I could not understand your words.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.