1
Hi there.
I'm trying to use the Criteria class to construct a "is not null" condition in SQL but with little luck.
i.e
le="color: #000000"><?php select * from xoops_users where uid is not null
Doing the above using Criteria
le="color: #000000"><?php $crit =& new Criteria('uid','0','','%s is not null');
produces
le="color: #000000"><?php select * from xoops_users where uid is not null 0
While
le="color: #000000"><?php $crit =& new Criteria('uid','','','%s is not null');
produces
le="color: #000000"><?php select * from xoops_users where
because no value is specified in the Criteria constructor.
The only way I have managed to do this is by hacking the criteria.php XOOPS class to the following:
le="color: #000000"><?php function render() { if ( is_numeric($this->value) || strtoupper($this->operator) == 'IN') { $value = $this->value; } else { if ( '' === ($value = trim($this->value)) ) { $value = null; } if ( (substr($value, 0, 1) != '`') && (substr($value, -1) != '`') ) { $value = "'$value'"; } } $clause = (!empty($this->prefix) ? "{$this->prefix}." : "") . $this->column; if ( !empty($this->function) ) { $clause = sprintf($this->function, $clause); } else { $clause .= " {$this->operator} $value"; } return $clause; }
Is this the only way of doing this? Am I missing something obvious? If not, can the above changes be incorporated into the core?
Cheers.
McNaz.