My previous post was all about my proposal for a database lookup validator for Zend Framework.
This proposal has now been accepted and is available in the incubator.
During the process of refining the proposal, Ralph Schindler suggested renameing the validator, and splitting it in two, to make it as verbose as possible (i.e. the name says exactly what it does). So, an abstract class has been added, and the DbMatch name dropped. The validators areĀ now called Zend_Validate_Db_RecordExists and Zend_Validate_Db_NoRecordExists. check the wiki page for more information.


#1 by https://me.yahoo.com/a/_41gcOhgj4XI1pAB.Kqq4oywuwkctg--#3822c on February 7, 2009 - 12:32 am
Hello,
first of all: Your Proposal is very usefull…
I’ve a question concerning this Validator: I’ve a “relation table” where user_ids and “other”_ids are inside. How can I validate this with your extension?
The Problem is, that I can add two times a Zend_Validate_Db_NoRecordExists Validator but this don’t matches the problem because its allowed to have by ex. a user_id multiple times in the table. Only the combinations are unique!
I hope you understand the problem
Greeting,
Robert
#2 by ryan on February 7, 2009 - 9:44 am
For this i would recommend using the ‘exclude’ feature, You can pass a string to the exclude parameter, allowing you to exclude one or more records from the seearch. in this case you would likely want to pass it a string, such as $validate = new Zend_Validate_Db_NoRecordExists(‘table’, ‘other_id’, ‘user_id = x’); where x is the id of your user. This would eliminate all records where the user_id is not the id of the user you are looking for, and then your search will only be for your unique combination.
I hope this helps!
#3 by Sudheer on March 6, 2009 - 1:15 pm
Cool. I have written these validators in several areas on my application. I will look forward for the component in 1.8.
#4 by Anonymous on March 3, 2010 - 12:34 pm