0

I am creating my second Zend Framework project (using 1.12) and have set it up just like the first (uses 1.11), but for some reason I am having problems connecting to my database using my class extending Zend_Db_Table. I have my database configuration in an ini file like this:

resources.db.adapter = "pdo_mysql"
resources.db.params.host = "localhost"
resources.db.params.username = "myUsername"
resources.db.params.password = "myPassword"
resources.db.params.dbname = "myDbname"
resources.db.isDefaultTableAdapter = true

Then I have my table class:

class Application_Model_DbTable_TestData extends Zend_Db_Table_Abstract {
    protected $_name = 'testdata'
}

and then in my controller I try:

$testdata = new Application_Model_DbTable_TestData();

and then when I go to the view for that controller I just get the message Application Error with no other info.

If I do the following in the controller:

$db = new Zend_Db_Adapter_Pdo_Mysql(array(
    'host'     => 'localhost',
    'username' => 'myUsername',
    'password' => 'myPassword',
    'dbname'   => 'myDbname'
));
$test = $db->select()->from(array('test' => 'testdata'));

I can get the data. Any ideas why I can't do it with the table class? As far as I can tell it's exactly the same as my other set up which works just fine.

Indrasinh Bihola
  • 2,094
  • 3
  • 23
  • 25
xena
  • 163
  • 1
  • 13
  • Make sure you're in development mode so you can see errors or exceptions. – Indrasinh Bihola Jan 20 '15 at 06:41
  • I do have it in development mode, and unfortunately, that's all the error message I get. I also forgot to mention that the new set up is on a different server. Not sure if it could be something that has to do with a different server setup. – xena Jan 20 '15 at 16:06
  • So I decided to change 'APPLICATION_ENV' from 'production' to 'development' to see if I could get more of an error message and that makes it work. I would still like to figure out why it won't work in production mode, but this is a temporary solution anyway. – xena Jan 20 '15 at 22:19
  • So what error message you get after you turn it into development?? – Indrasinh Bihola Jan 21 '15 at 04:54
  • Have you added the settings under correct section in application.ini? – Amit Kriplani Jan 21 '15 at 16:36
  • Indrasinh, when I switch to development I don't get any errors, it works in development mode. Strange but true. – xena Jan 21 '15 at 21:46

1 Answers1

0

It turned out that the problem was where I had the database configuration data placed in my ini file. It was directly under [development : production] so development was the only thing that was getting it. Just one of those stupid oversights where I had to step away for a while and look again later to see it.

xena
  • 163
  • 1
  • 13