GregL83 Posted July 14, 2010 Share Posted July 14, 2010 I posted something earlier... I upgraded to Zend Framework 1.10. I haven't done a DB connection with Zend before. I am extremely frustrated with the setup. I have my application.ini file as follows: database.adapter = "PDO_MYSQL" database.params.host = "localhost" database.params.dbname = "test" database.params.username = "root" database.params.password = "" database.params.isDefaultTableAdapter = true And inside my index controller inside the index action i'm calling the following line to access the DB: $db = Zend_Db_Table_Abstract::getDefaultAdapter(); $db->fetchAll('SELECT * FROM test1'); Is my understanding that Zend will automatically setup the DB resource with my ini settings as is... But I keep recieving the error: Call to a member function fetchAll() on a non-object I have passed one forum where this exact method is being used. For the life of me I cannot seem to access the DB. And zend tutorials/guides/docs with all the different versions just plain suck. Here is where I found a resource: http://www.zfforums.com/zend-framework-components-13/databases-20/applicationi-ini-connect-db-2936.html Quote Link to comment https://forums.phpfreaks.com/topic/207688-zend-110-db-connection-frustration/ Share on other sites More sharing options...
Cagecrawler Posted July 19, 2010 Share Posted July 19, 2010 A couple of things: - You can't instantiate an abstract class. You need to extend it first. - Have you set the default adapter? $db = Zend_Db::factory('PDO_MYSQL', $options); Zend_Db_Table_Abstract::setDefaultAdapter($db); Quote Link to comment https://forums.phpfreaks.com/topic/207688-zend-110-db-connection-frustration/#findComment-1088391 Share on other sites More sharing options...
Jaguar Posted July 20, 2010 Share Posted July 20, 2010 Use Zend_Db_Table, not Zend_Db_Table_Abstract (e.g. "$db = Zend_Db_Table::getDefaultAdapter();") Quote Link to comment https://forums.phpfreaks.com/topic/207688-zend-110-db-connection-frustration/#findComment-1088706 Share on other sites More sharing options...
GregL83 Posted July 28, 2010 Author Share Posted July 28, 2010 I tried both. I am able to do Cagecrawler's method; however, i want to be able to get the db object from the config.ini params... Quote Link to comment https://forums.phpfreaks.com/topic/207688-zend-110-db-connection-frustration/#findComment-1092363 Share on other sites More sharing options...
GregL83 Posted July 28, 2010 Author Share Posted July 28, 2010 i'm under the impression that zend should automatically register the default adapter declared in my config.ini/application.ini file... i have been able to get an adapter obj other ways, but I want to know why I can't do it the way described in the zend tutorial. this seems to be the standard way but i cant get it to work.... does it matter that the db wasn't created in the cmd line??? Quote Link to comment https://forums.phpfreaks.com/topic/207688-zend-110-db-connection-frustration/#findComment-1092370 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.