ZF-7953: Zend_Validate_Db_Abstract should use getter for adapter

Issue Type: Patch Created: 2009-09-24T19:11:50.000+0000 Last Updated: 2009-10-05T19:07:42.000+0000 Status: Resolved Fix version(s): - 1.10.0 (27/Jan/10)

Reporter: David Muir (dmuir) Assignee: Thomas Weidner (thomas) Tags: - Zend_Validate

Related issues: Attachments: - library.diff


It would make extensions to the Zend_Validate_Db validators a bit easier if the db adapter was accessible via a getter.

Use case: I need a validator that can validate against the context, so I set it up so that I can use placeholders in the exclude parameter that get swapped out with corresponding values from the context. To get the context values quoted, I need access to the adapter, except that I can't use $this->_adapter, as it hasn't been initialised yet. So I end up having to copy the init code from Zend_Validate_Db_Abstract::_query()


Posted by David Muir (dmuir) on 2009-09-24T19:14:09.000+0000

Patched Zend_Validate_Db_Abstract with new getter method

Posted by Thomas Weidner (thomas) on 2009-09-25T11:44:21.000+0000

Patch unusable. Added feature as part of another on with r18417

Posted by David Muir (dmuir) on 2009-10-04T21:48:08.000+0000

Although r18417 added a getter/setter for the adapter, it would be more useful to let the getter have a default fallback like there is in the _query method. Otherwise each extensions requiring the adapter needs to duplicate that part of the query method, which is the reason why I raised the issue in the first place.

Could you give me a reason why my patch was rejected? Would be helpful for future contributions.

Posted by Thomas Weidner (thomas) on 2009-10-05T11:39:24.000+0000

Your "patch" did not conform the API. When you add a getter you must also add a setter. When you do this for one option you should also do this for all other options, not only for a single one.

Related to _query: getAdapter return only what has been set. A default adapter is not set by the user, so it's not returned by getAdapter. And the adapter option can also be optional or set afterwards. So it is not filled per default.

Extending classes will not have to duplicate the adapter code, but simply use/extend _query for their own purposes.

Posted by David Muir (dmuir) on 2009-10-05T19:07:22.000+0000

But that's precisely the point. You cannot have an extension use the default adapter prior to querying without : 1. Duplicating the "get default adapter" code in _query() or 2. Providing a getter for it

Have you found an issue?

See the Overview section for more details.


© 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.