There was something else I was going to mention. You could probably
get rid of all those if (!empty()) checks where you're doing a simple
equality comparison in your query and instead do a call to Set::filter
() on the array. For example you could get rid of statements like:
$conditions['School.zip_mail'] = $formSchools['zip_mail'];
$conditions['School.street_mail'] = $formSchools['street_mail'];
$conditions['School.state_mail'] = $formSchools['state_province'];
These statements are checking for records that have fields equal to
some value. As you mentioned before, the form results array had empty
values in them where conditions were not entered for those respective
fields. Set::filter() will remove all elements in that array that are
empty, which can greatly simplify things.
You could do a:
$formSchools = Set::filter($this->data['schools']);
instead of:
$formSchools = $this->data['schools'];
Then to get the "School." prefix for all the array keys in
$formSchools, you can do something like this:
$formSchools = array_combine(preg_replace("/.+/", "School.$0",
array_keys($formSchools)), array_values($formSchools));
Next, you might do something like this for the special case of the
'name' field or any other field where you might use similar operators:
$formSchools['School.name LIKE'] = "%{$formSchools['School.name']}%";
unset($formSchools['School.name']);
All of that might seem like more work, but I just thought I'd throw
those tidbits out there if you were interested.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---