Zend Db Adapter Exception
Bonjour à Tous,
voila je suis newbie dans l'utilisation de Zend Framework, ca ne fait que 2 3 jours que je m'y suis mis dans le but de réaliser une application web !
Voila mon soucis, je cherchais donc à utiliser Zend_Db_Table pour établir un dialogue avec une base de donnée. J'ai vu que Zend Framework proposait une classe Zend_Config pour un accès orienté objet aux fichiers de configuration.
Mon fichier config.ini
Code:
1 2 3 4 5 6 7
|
[general]
db.adapter= PDO_MYSQL
db.params.host= localhost
db.param.username= root
db.params.password=
db.params.dbname= zftest |
et donc dans mon fichier index.php je charge le fichier de config
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
include "Zend/Loader.php";
Zend_Loader::registerAutoload();
$config = new Zend_Config_Ini(APPLICATION_PATH . 'config.ini','general');
$dbAdapter = Zend_Db::factory($config->db);
Zend_Db_Table_Abstract::setDefaultAdapter($dbAdapter);
$registry = Zend_Registry::getInstance();
$registry->config = $config;
$registry->dbAdapter = $dbAdapter;
$frontController = Zend_Controller_Front::getInstance();
$frontController->throwExceptions(true);
$frontController->setControllerDirectory(APPLICATION_PATH . '/controllers');
Zend_Layout::startMvc(APPLICATION_PATH . '/layouts/scripts');
$frontController->dispatch(); |
Cepedant je me retrouve avec une erreur que je n'ais pas encore trop bien saisi :roll:
Citation:
Fatal error: Uncaught exception 'Zend_Db_Adapter_Exception' with message 'Configuration array must have a key for 'username' for login credentials' in C:\wamp\www\WebApp\library\Zend\Db\Adapter\Abstract.php:264 Stack trace: #0 C:\wamp\www\WebApp\library\Zend\Db\Adapter\Abstract.php(175): Zend_Db_Adapter_Abstract->_checkRequiredOptions(Array) #1 C:\wamp\www\WebApp\library\Zend\Db.php(253): Zend_Db_Adapter_Abstract->__construct(Array) #2 C:\wamp\www\WebApp\public\index.php(13): Zend_Db::factory(Object(Zend_Config)) #3 {main} thrown in C:\wamp\www\WebApp\library\Zend\Db\Adapter\Abstract.php on line 264
Quelqu'un pourrais m'aider ?? :oops: