Issues

ZF-2921: Allow defining of the schema separator in Zend_Db_Adapter

Issue Type: Improvement Created: 2008-03-19T08:50:05.000+0000 Last Updated: 2013-03-13T20:55:26.000+0000 Status: Open Fix version(s): - Next Mini Release ()

Reporter: Giacomo Tesio (shamar) Assignee: Ralph Schindler (ralph) Tags: - Zend_Db

  • Zend_Db_Select
  • Zend_Db_Table

Related issues: Attachments: - library_Zend_Db.diff

Description

To simulate the schema system in RDBMS which don't support it (as MySQL, where SCHEMA is a DATABASE) 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 by simply changing the '.' string with a call to Zend_Db_Adapter_Abstract::getSchemaSeparator() in the following methods: 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()

So you could extend an Adapter (eg MySQLi) by definig the attribute $_schemaSeparator (say with '__') and you get a sort of schema management analogue of PostgreSQL one (for example), to group table in namespaces.

I've also build a patch you could find in http://dev.tesio.it/patch.Zend_Db

The work estimate contain simply adding the patch to the core CVS and testing more widely...

Comments

Posted by Giacomo Tesio (shamar) on 2008-03-19T08:51:28.000+0000

The patch I wrote...

Posted by Wil Sinclair (wil) on 2008-03-25T20:25:42.000+0000

Please categorize/fix as needed.

Posted by Giacomo Tesio (shamar) on 2008-04-08T09:40:18.000+0000

I realized that, when using such a feature, you should set Adapter::$_autoQuoteIdentifiers = FALSE: otherwise, a "virtual schema" called "schema" and a table named "test_table" with an Adapter::$_schemaSeparator = '__' you would get a query quoting the table as schema__test_table which is clearly wrong.

To make it work better I'm wondering of a protected _schemaSperatator setter (say Adapter::_setSchemaSeparator(string $separator, boolean $explodeIdentifiers = false) )

$explodeIdentifiers set a protected Adapter boolean attribute (defined true by default in Zend_Db_Adapter_Abstract) which enable / disable the explode() call in Zend_Db_Adapter_Abstract::_quoteIdentifierAs()

What do you think about this?

Posted by Giacomo Tesio (shamar) on 2008-04-09T02:43:40.000+0000

Here an updated Patch which fix a little bug in Zend_Db_Adapter_Abstract::_joinUsing() and follow the contributer guide (aka, built using svn diff)

Posted by Wil Sinclair (wil) on 2009-01-06T10:48:58.000+0000

No action on this issue for too long. I'm reassigning to Ralph for re-evaluation and categorization.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts