I am currently trying to develop a module for XOOPS, and found some strange behaviour in the CriteriaElement and related classes. Maybe somebody could help or let me know if I am using them in the wrong way.
First I found that when you do the following:
le="color: #000000"><?php $criteria =& new CriteriaCompo(); $criteria->add(new Criteria('text1', ''); $criteria->add(new Criteria('text2', $text2);
the render of the WHERE clause is not correctly formatted and it ends up with:
le="color: #000000"><?php WHERE AND text2='sample text'
instead of:
le="color: #000000"><?php WHERE text1 = '' AND text2 = 'sample text'
It basically means that we cannot look for an empty string in a table.
Furthermore, I have try to use the CriteriaElement objects to look for NULL columns in the database, and it does not work too. If I do:
le="color: #000000"><?php $criteria =& new CriteriaCompo(); $criteria->add(new Criteria('text1', null, '<=>'); $criteria->add(new Criteria('text2', $text2);
the same happen.
It looks like the two problems are coming from the following lines in the Criteria::render() function:
le="color: #000000"><?php if ( '' === ($value = trim($this->value)) ) { return ''; }
Is it intentional? How can I look for an empty column using the CriteriCompo object?
Same questions for the NULL columns? For this one, I had to add the following lines at the beginning of the Criteria::render() function:
le="color: #000000"><?php if (is_null($this->value)) { $value = 'NULL'; } else ...
Thanks for your help.
BTW congratulation to the XOOPS team! XOOPS is great, I love it.