View Single Post
  #1 (permalink)  
Old 03-18-2008, 07:40 AM
Shamar Shamar is offline
Junior Member
 
Join Date: Mar 2008
Posts: 3
Lightbulb Schema separator in Zend_Db_Table_Abstract and Zend_Db_Adapter_Abstract (patch???)

Hello Everybody!

I'm really happy of seing Zend_Framework 1.5 up!
I'm developing a (not so) little project for a little publishing house, and I choose Zend_Framework 1.5 when it was yet RC1... (being a bit afraid for it's stability).
Now it's stable, I'm far more happy of my choose!

Going to my request, I'm developing on a DBMS which doesn't support schema definition (aka MySQL).
But, for many reasons, I need a system which could work in PostgreSQL too, by simply changing the adapter.
Moreover I NEED to use the schema abstraction (mainly for keep clean namespaces).

Now to simulate the schema in MySQL I thought to patch the Zend_Db_Adapter_Abstract by adding a protected attribute called Zend_Db_Adapter_Abstract::$schemaSeparator (default to ‘.’) and a public method Zend_Db_Adapter_Abstract::getSchemaSeparator()

Then to modify the methods

PHP Code:
Zend_Db_Table_Abstract::_setupMetadata() 
Zend_Db_Table_Abstract::_setupTableName()
Zend_Db_Table_Abstract::_setupPrimaryKey()
Zend_Db_Table_Abstract::insert()
Zend_Db_Table_Abstract::update
Zend_Db_Table_Abstract
::delete()
Zend_Db_Select::__toString()
Zend_Db_Select::_join() 
to use $this->_db->getSchemaSeparator() instead of ‘.’

This way, you could extend the adapter you want, and by setting the $schemaSeparator attribute (say with '__') all the rest will work with tables named as schema__table1 schema__table2 and so on...

I know I could simply extends all those objects, but since this is a patch which could be useful to others (and seem to not have backward compatibility issue), I prefer to contribute the framework.
(also becouse I'm lazy, and don't want to monitor the Zend_Db module for such a patch submitted for someone else).

Btw, I don’t know how to submit this patch (as you can see, quite easy to write).

Obviously it’s not the same of having a real schema DBMS, but some time this could help.


Can you help me?
Have you some suggestions?


Thank you all!


Shamar
Reply With Quote