1
I really dont know why we cannot use empty value in criteria?
e.g.: i want to add this:
$criteria->add(new Criteria("groups", "", "!="));
but class xoops255/class/criteria.php dont allow it in render function.
public function render()
{
$clause = (!empty($this->prefix) ? "{$this->prefix}." : "") . $this->column;
if (!empty($this->function)) {
$clause = sprintf($this->function, $clause);
}
if (in_array(strtoupper($this->operator), array('IS NULL', 'IS NOT NULL'))) {
$clause .= ' ' . $this->operator;
} else {
if ('' === ($value = trim($this->value))) {
return '';
}
if (!in_array(strtoupper($this->operator), array('IN', 'NOT IN'))) {
if ((substr($value, 0, 1) != '`') && (substr($value, -1) != '`')) {
$value = "'{$value}'";
} else {
if (!preg_match('/^[a-zA-Z0-9_.-`]*$/', $value)) {
$value = '``';
}
}
}
$clause .= " {$this->operator} {$value}";
}
return $clause;
}
it is these lines:
if ('' === ($value = trim($this->value))) {
return '';
}
I dont know why core team decide to add these?
sometimes we need this sql:
SELECT * FROM `table` WHERE column IS NOT NULL AND TRIM(column) <> ''
or this:
SELECT * FROM `table` WHERE column IS NOT NULL AND column <> ''
but we cannot.