The Criteria::render() function currently returns an
empty string (without any statement) if you build a
query to search for an empty string, e.g. doing:
$criteria = new Criteria('text1', '');
and calling
$criteria->renderWhere();
it will not render any WHERE statement but will return
an empty string.
To allow this, modify the function Criteria::render()
(file class/criteria.php) replacing the lines:
if ( '' === ($value = trim($this->value)) ) {
return '';
}
with
$value = trim($this->value);
Furthermore, the Criteria::render() function does not
allow to make queries looking for columns that are
NULL. To allow this, modify the beginning of the
Criteria::render() function adding:
if (is_null($this->value)) {
$value = 'NULL';
} else
before the first line of the function which is:
if ( is_numeric($this->value) ||
strtoupper($this->operator) == 'IN') {
Then you can do:
$criteria = new Criteria('length', null, '<=>');
and retrieves the rows with NULL value.
All this works on XOOPS 2.0.6 running a MySQL database
(I am not sure it will work with other database
engine... Will it?)
I hope it can help anybody, and that it will be
included in future releases of XOOPS.
Logged In: YES
user_id=882380
OK for that one. Am keeping this one for 2.2 as this should
go to beta before release (some modules might rely on this
misbehavior).