Zend Framework: Zend_DB Error -


I'm trying to learn ZFF, but got a strange error after 20 minutes :)

 Fatal error: Unsecured exception 'Zend_Db_Adapter_Exception' with 'Message' configuration array should be a key for 'dbname' which is the name of the database instance ' 

What is the error? the meaning is? I found DB information in my config file:

  resources.db.adapter = pdo_mysql resources.db.host = localhost resources.db.username = name resource.db.password = close resources.db .dbname = name  

Any suggestions?

Edit:

This is my model file /app/models/DbTable/Bands.php:

  class matches Model_DbTable_Bands Zend_Db_Table_Abstract { Protected $ _name = 'zend_bands'; }  

index controller action:

  public function index () {$ album = new Model_DbTable_Bands (); $ This- & gt; View- & gt; Album = $ album- & gt; Fatch ALL (); }  

Edit all code:

bootstrap.php

  secure function _initAutoload () {$ autoloader = new Zend_Application_Module_Autoloader ( Array ('namespace' => gt; '', 'base path' = & gt; dirname (__ FILE__),)); $ Autoloader return; } Safe Function _Inte DockType () {$ this-> Bootstrap ('view'); $ View = $ it- & gt; GetResource ('view'); $ View-> Doctype ('XHTML1_STRICT'); } Public Fixed Work Setup Database () {$ config = self :: $ registry- & gt; Configuration; $ Db = Zend_Db :: Factory ($ config- & gt; db); $ Db- & gt; Query ("SET NAMES 'utf8'"); Self: $ Registry- & gt; Database = $ db; Zend_Db_Table :: setDefaultAdapter ($ Database); Zend_Db_Table_Abstract :: setDefaultAdapter ($ Database); } {/ Code>  

IndexController.php

  class index controller Zend_Controller_Action extended {public function init ()} / / start action controller here / / public function index ( ) {$ Album = New Model_DbTable_Bands (); $ This- & gt; View- & gt; Album = $ album- & gt; Fatch ALL (); }}  

configs / application.ini, changed database and provided password:

  [development: production] phpSettings.display_startup_errors = 1 phpSettings.display_errors = 1 Db.adapter = PDO_MYSQL db.params.host = localhost db.params.username = root db.params.password = pedro db.params.dbname = test  

Model / DBTable / Band Php

  Class Model_DbTable_Bands Expands Zend_Db_Table_Abstract {protected $ _name = 'cakephp_bands'; Public function getAlbum ($ id) {$ id = (int) $ id; $ Line = $ this- & gt; FetchRow ('id ='. $ Id); If (! $ Line) {Throw New Exception ("Can not find quote line $ id"); } $ Line-> ToArray (); }}  

To end this discussion at the end with the right solution, here I have:

application.ini:

  resources.db.adapter = mysqli processing.db.params.dbname = zftutorial resources.db.params.host = localhost resources .db. 


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -