1.0 - 10 October 2008: Initial Draft.
1.1 - 10 October 2008: Revised class skeleton to use fetchRow and limit(1) after discussion with Shane Lilge (Toppy).
1.2 - 11 October 2008: Revised class skeleton after discussion with Ben Scholzen (DASPRiD) and Robin Skoglund (robinsk).
1.3 - 26 November 2008: Revised class skeletons, added utility table.
1.4 - Added Abstract class. (wiki revision: 37)
The process of checking user input against a database to check for the presence or absence of a matching record is pretty common place.
This process currently will end up either in your model or controller, when it should in fact be in the validation of your form.
The usage of these validators will negate the need to perform a validity check against a form, pass that to the controller, check it against the model, and then pass it back to the user with the appropriate feedback.
This will also simplify the process of providing user feedback.
2. References
3. Component Requirements, Constraints, and Acceptance Criteria
Zend_Validate_Db_RecordExists will confirm a record exists in a table
Zend_Validate_Db_NoRecordExists will confirm a record does not exist in a table
Both components will allow a single record to be excluded, or a sql string to be added as a where clause to exclude records from the select.
ZF-3486 Should be resolved, to allow the decision whether to drop the class Zend_Validate_Db_Table to be made.
4. Dependencies on Other Framework Components
Zend_Validate_Abstract
Zend_Db_Table_Abstract
Zend_Db_Table_Adapter
5. Theory of Operation
An abstract class provides initialisation for two classes. An instance of Zend_Db_Table will be created to fetch the adapter to use for queries.
The abstract class will also provide a method to build the query.
If a sql where clause or an array containing field and value keys is given, a record may be omitted from the query.
6. Milestones / Tasks
Milestone 1: design notes will be published here
Milestone 2: Working prototype checked into the incubator supporting use cases #1
Milestone 3: Unit tests exist, work, and are checked into SVN.
<p>Would have liked to have had this on my last couple of projects. Would have saved some time and added clarity in several places. Very handy. I'll definitely use this in upcoming projects and would like to see it in ZF.</p>
<p>This component is accepted to the <strong>Standard Incubator</strong>.</p>
<p>One area we'd like to see improve is the removal of the Zend_Validate_Db_Table class. If the goal is to be able to get a default adapter, Zend_Db_Table_Abstract::getDefaultAdapter() === null should suffice in that respect. If you have any additional comments on that one concern, by all means, please address them with me either here, mail or IRC.</p>
<p>Wil, Yes. I believe I just have to finish the unit tests and write the documentation. I will try and get those done some time in the next week.<br />
Is there a date for the 1.8 release yet?</p>
6 Comments
comments.show.hideOct 10, 2008
Shane Lilge
<p>Would have liked to have had this on my last couple of projects. Would have saved some time and added clarity in several places. Very handy. I'll definitely use this in upcoming projects and would like to see it in ZF.</p>
Jan 09, 2009
Ralph Schindler
<ac:macro ac:name="note"><ac:parameter ac:name="title">Official Zend Response</ac:parameter><ac:rich-text-body>
<p>This component is accepted to the <strong>Standard Incubator</strong>.</p>
<p>One area we'd like to see improve is the removal of the Zend_Validate_Db_Table class. If the goal is to be able to get a default adapter, Zend_Db_Table_Abstract::getDefaultAdapter() === null should suffice in that respect. If you have any additional comments on that one concern, by all means, please address them with me either here, mail or IRC.</p>
<p>-ralph</p>
</ac:rich-text-body></ac:macro>
Jan 15, 2009
removed user
<p>Excellent addition! </p>
Mar 18, 2009
Wil Sinclair
<p>Ryan, do you plan to have this ready for the 1.8 release? Please let me know by replying here.</p>
Mar 19, 2009
Ryan Mauger
<p>Wil, Yes. I believe I just have to finish the unit tests and write the documentation. I will try and get those done some time in the next week.<br />
Is there a date for the 1.8 release yet?</p>
Mar 31, 2009
Ryan Mauger
<p>Tests and documentation are now in incubator.</p>