2

I am trying to work out what would be the fastest way to compare user data which has been entered into a form with user data that is already stored in the database.

My plan was to pull all details of a single column into an array i.e. email, then compare them with the value entered, but I think that will get vary slow as the database grows.

My second idea was to use Zend_validate::is($email,'email') but that throws the error 'Validate class not found from basename'. The only information I can find on this error is references to a bug.

My question is: When comparing value from a form and database what would produce the quickest results?

EDIT

This is part of a custom module (my first one)

I am trying to avoid duplications within my table

The module will provide me with a list of people who are not members but want information specific events

asked Jul 26, 2013 at 11:28
3
  • That method will try to validate that the input is an email. Are you trying to prevent duplicates in the DB? Magento prevents duplicate emails for customers - are you modifying/extending something? Commented Jul 26, 2013 at 11:32
  • 2
    Are you intending to validate client-side? What problem are you trying to solve (e.g. "account already exists")? Commented Jul 26, 2013 at 11:43
  • Please see my edit and I would like to validate, both client and server side Commented Jul 26, 2013 at 12:13

1 Answer 1

1

You could do one of a few things here. These are the two I would suggest, but that is mainly personal opinion.

  1. Validate before you save the object - have a look at how the customer object works, basically it has a validate function that does some checks and if any throws an error then it adds them to an error array. Then simply call this before you save your model and only save when the error array is empty,
  2. Ajax validation - you could add a ajax call before you submit your form, either on blur of the field or simply before the form is submitted, then what you can do is call some controller somewhere that checks to see if their is already an entity saved with this information. If there is then show the error, otherwise submit the form as normal,
answered Jun 27, 2014 at 10:57

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.