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:
$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:
WHERE AND text2='sample text'
instead of:
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:
$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:
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:
if (is_null($this->value)) {
$value = 'NULL';
} else ...
Thanks for your help.
BTW congratulation to the XOOPS team! XOOPS is great, I love it.