My boss wants the application we are currently working on to be split across several schemata in the database, because he wants multiple applications — some of which I have no control over — to be able to access the data, following a naming convention like DeploymentPrefix_Category. For instance, there’d be a few schemata for production, Production_Foo, Production_Bar, and Production_Baz, and then the same for staging Staging_Foo, Staging_Bar, and Staging_Baz, and the same for development.
The problem is that while Zend_Db_Table lets me specify a schema, it doesn’t seem to let me generate that schema on the fly, which I would need to do to put that prefix on the schema.
What’s the best way to handle that?
The issue of different configs for different environments is easily handled with Zend_Config. See the section on config in the quickstart:
http://framework.zend.com/manual/en/learning.quickstart.create-project.html
This allows you to specify different settings for each environment.
As for the schemas, I’m guessing you have some tables that live in Production_Foo and others that live in Production_Bar. Consider extending Zend_Db_Table for each of these schemas and pointing to the correct database at the time of construction.
Zend_Db_Table’s constructor is defined as follows:
When we follow through to see where $definition leads it allows you to pass an array that is loaded into Zend_Db_Table_Definition. One of the options for this is the table name:
As for your schema, you just pass in different set of options for the db adapter that points to the correct one.