0

I have taken over an application written with the use of the Zend MVC and Zend_Db_Table for DB access. I am trying to add a new table but get the error:

Base table or view not found: 1146 Table 'maa_agencies.contact' doesn't exist

However maa_agcencies.contact very much DOES exists and is in the same DB as the rest of the tables being accessed.

Here are my steps and code:

Step 1:

Create the Model Class

file: application/models/DbTable/Contact.php

class Model_DbTable_Contact extends Zend_Db_Table_Abstract
{
    protected $_name = 'contact';
}

Step 2:

Instantiate the Class the same way it's done a dozen time in a controller (all other tables work)

file: application/modules/agency/controllers/IndexController.php (also step 3)

$agency_contact = new Model_DbTable_Contact();

Step 3:

Write my data to my new table ($store_contact is an assoc array with key = column name value = value)

$agency_contact->insert($store_contact);

Is there some caching function in Zend I am unaware of?

Some special thing I need to do to tell it I added a new table?

All documentation I have come across says this is all that is required, and as I state above the file I am trying to access my table through is already accessing 2 other tables in the same DB, in fact the line just above where I instantiate my Contact model is this statement that works fine:

$sm = new Model_DbTable_SentEmail();

The name space idea seems awesome! If this system wasn't some bastardization of the framework. Here is a currently working Model

/**
 * @category    Model_DbTable
 * @package     Model_DbTable_States    

class Model_DbTable_States extends Zend_Db_Table_Abstract
{
  protected $_name = 'state_list';
}

Is there some vodoo in the commenting perhaps, I am unable to find anywhere in the code where a namespace is registered at all.

Zjoia
  • 176
  • 3
  • 16
  • perhaps there is a way to like reinitialize the DB connection and rebuild some hidden schema file somewhere? I wouldn't imagine it checks the DB schema each time a connection is made there has to be a cached version somewhere that can be refreshed. – Zjoia Oct 18 '12 at 17:47

2 Answers2

0

Change your Class names of Model Directory. Add Prefix Application_

Example: Application_Model_DbTable_Contact
Vijay Sarin
  • 1,326
  • 1
  • 11
  • 31
0

You forgot to add the namespace to your class

class Yournamespace_Model_DbTable_Contact extends Zend_Db_Table_Abstract
{
    protected $_name = 'contact';
}

IN your application.ini ad this line

autoloaderNamespaces[] = "Yournamespace_"
coolguy
  • 7,866
  • 9
  • 45
  • 71
  • the namespace is set to blank in this project. Somewhere there is a file defining the schema, there has to be. I just altered a table that is currently working in this system and I get a similar error, it says the column I added does not exist. Any idea on where I can look for such a definition, I've greped over this entire project 100 times looking for any answer and there is nothing to be found. I'm at a total loss. – Zjoia Oct 18 '12 at 17:46