filter attribute with beetwen

Permalink
Hi,

I would like to know if there are any way to filter an user attribute by the between clause.

Because this isn't working:
$ul->filterByAttribute('user_attribute_key_handle', $min. " AND " .$max, 'BETWEEN');

It handles the $min and $max as string, but they are integers.

Thanks for your rply

 
shahroq replied on at Permalink Best Answer Reply
shahroq
For special cases like this you can use filter method and pass your criteria directly in it:
filter(false, '(user_attribute_key_handle BETWEEN 1 AND 2)');

but if you are insisted on using filterByAttribute you can 2 of them, one for bigger and one for smaller:
$ul->filterByAttribute('user_attribute_key_handle', $min , ">" );
$ul->filterByAttribute('user_attribute_key_handle', $max , "<" );
leventekorponai replied on at Permalink Reply
Thank you!
$ul->filterByAttribute('user_attribute_key_handle', $min , ">" );
$ul->filterByAttribute('user_attribute_key_handle', $max , "<" );


This worked for me...
And also my mistake was that, the attribute type was text, so i had to change it to number, and now everything works well.