Forum
Perch_content_custom: Null is not null?
I have a dataselect
with allowempty="true"
. This results in the value of this field being NULL
.
However, when passing that into a perch_content_custom
filter...
$thing = perch_content_custom('MyRegion', array(
'skip-template' => 'true',
'filter' => 'my-field',
'match' => 'eq',
'value' => NULL
));
...rather than finding no match and returning nothing, it always returns the first item of that region.
If value
is ''
or false
, it returns nothing as expected.
I can get round this for now with something like if ($thing[0]['my-field'] == NULL) { $thing[0]['my-field'] = false; }
but wondered if there was a more fundamental issue here?
I should add, I am not actually passing
NULL
, but a variable which is set toNULL
- just simplified the above example for easier debugging.Actually I can fix if by wrapping
perch_content_custom
inif ($thing[0]['my-field'])
- no point even querying Perch if it isNULL
.Still, odd that
NULL
would return first result...I shall take a look.
Nice one - no urgency whatsoever, just a curiosity.