1
irmtfan
XOOPS255 and XOOPS26 bug: cannot use this: $criteria->add(new Criteria("FIELD", "", "<>"))
  • 2013/4/10 9:11

  • irmtfan

  • Module Developer

  • Posts: 3419

  • Since: 2003/12/7


I really dont know why we cannot use empty value in criteria?

e.g.: i want to add this:
le="color: #000000"><?php $criteria->add(new Criteria("groups", "", "!="));


but class xoops255/class/criteria.php dont allow it in render function.
le="color: #000000"><?php 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:
le="color: #000000"><?php if ('' === ($value = trim($this->value))) { return ''; }


I dont know why core team decide to add these?

sometimes we need this sql:
le="color: #000000"><?php SELECT * FROM `table` WHERE column IS NOT NULL AND TRIM(column) <> ''


or this:
le="color: #000000"><?php SELECT * FROM `table` WHERE column IS NOT NULL AND column <> ''


but we cannot.