Mmmh, why not this way?
---
$this->listOfMembersWhoMeetSearchCriteria = array();
$c = new Criteria();
$uvaStatusArray = $request->getParameter('uva_status');
if (is_array($uvaStatusArray)) {
for ($i=0; $i < count($uvaStatusArray); $i++) {
if ($i > 0) {
$c->addOr(sfGuardUserProfilePeer::UVA_STATUS,
$uvaStatusArray[$i]);
} else {
$c->add(sfGuardUserProfilePeer::UVA_STATUS, $uvaStatusArray
[$i]);
}
}
}
if (count($uvaStatusArray)){
$this->listOfMembersWhoMeetSearchCriteria =
sfGuardUserProfilePeer::doSelect($c);
}
else{
$this->listOfMembersWhoMeetSearchCriteria = array();
}
---
It's a workaround, but it works :)
Frank
Am 01.09.2009 um 06:19 schrieb Jake Barnes:
>
>
> Untill we get Lucene working, I was going to write some simple code
> that would allow very simple searches. So I tried this:
>
>
> $this->listOfMembersWhoMeetSearchCriteria = array();
> $c = new Criteria();
>
> $uvaStatusArray = $request->getParameter('uva_status');
> if (is_array($uvaStatusArray)) {
> for ($i=0; $i < count($uvaStatusArray); $i++) {
> if ($i > 0) {
> $c->addOr(sfGuardUserProfilePeer::UVA_STATUS,
> $uvaStatusArray[$i]);
> } else {
> $c->add(sfGuardUserProfilePeer::UVA_STATUS, $uvaStatusArray
> [$i]);
> }
> }
> }
>
> $this->listOfMembersWhoMeetSearchCriteria =
> sfGuardUserProfilePeer::doSelect($c);
>
>
> This works well, except for when uva_status is empty. If uva_status is
> empty, then the code arrives on the last line without any conditions
> having been added to the Criteria object, so every row in the database
> is returned. This is the opposite of what I want. Is there any way to
> test and see whether conditions have been added to the Criteria
> object?
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony users" 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/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---