public function testToStringFunction() { $types = array('pcounter()' => MW_DB_Statement_Abstract::PARAM_INT, 'strconcat()' => MW_DB_Statement_Abstract::PARAM_STR, 'lcounter()' => MW_DB_Statement_Abstract::PARAM_INT); $translations = array('pcounter()' => 'count($1,$2,$3)', 'strconcat()' => 'concat($1,$2)', 'lcounter()' => 'count(name IN ($1))'); $expr = new MW_Common_Criteria_Expression_Compare_SQL($this->_conn, '==', 'pcounter("name",10,0.1)', 3); $this->assertEquals("count('name',10,0.1) = 3", $expr->toString($types, $translations)); $expr = new MW_Common_Criteria_Expression_Compare_SQL($this->_conn, '~=', 'strconcat("hello","world")', 'low'); $this->assertEquals("concat('hello','world') LIKE '%low%'", $expr->toString($types, $translations)); $expr = new MW_Common_Criteria_Expression_Compare_SQL($this->_conn, '==', 'lcounter(["a","b","c","\'d"])', 4); $this->assertEquals("count(name IN ('a','b','c','''d')) = 4", $expr->toString($types, $translations)); $expr = new MW_Common_Criteria_Expression_Compare_SQL($this->_conn, '==', 'lcounter([])', 0); $this->assertEquals("count(name IN ()) = 0", $expr->toString($types, $translations)); }
/** * Returns the available compare, combine and sort operators. * * @return array Associative list of lists (compare, combine, sort) containing the available operators */ public function getOperators() { return array('combine' => MW_Common_Criteria_Expression_Combine_SQL::getOperators(), 'compare' => MW_Common_Criteria_Expression_Compare_SQL::getOperators(), 'sort' => MW_Common_Criteria_Expression_Sort_SQL::getOperators()); }