I want to ignore case in a filter , My code:
if (strtolower(isset($filterObject['name'])) && null !== strtolower(($filterObject['name']))) {
$queryFilter->addStringFilter("name", ($filterObject['name']));
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you want to ignore the casesensitivity of the addStringFilter by lowercasing the object
you would just have to use strtolower($filterObject[‘name’]).
strtolower lowercases the string given.
On that note you are using strtolower on an isset function result which won’t do a thing there (as isset returns no string).
So you should change your sourcecode to:
Btw one case you didn’t check is if $filterObject[‘name’] is empty (not sure if it is possible as I don’t know your remaining code. If it CAN be possible you want to add another and into the if:
That would make sure that it is filled with more than an empty string.
Thus the if part would change to: