protected function _sqlCondition($field, $compare, $value) { $fid = Oops_Sql_Common::escapeIdentifiers($this->_useAlias ? $this->_alias . '.' . $field : $field); $cond = $fid . ' '; switch ($compare) { case self::CMP_NULL: $cond .= 'IS NULL'; break; case self::CMP_NOTNULL: $cond .= 'IS NOT NULL'; break; case self::CMP_NE: $cond .= is_array($value) ? 'NOT ' : '!'; case self::CMP_EQ: if (is_array($value)) { $cond .= 'IN (' . join(',', array_map(array('Oops_Sql_Common', 'quoteValue'), $value)) . ')'; } else { $cond .= '= ' . Oops_Sql_Common::quoteValue($value); } break; case self::CMP_GT: case self::CMP_LT: case self::CMP_GE: case self::CMP_LE: if (is_array($value)) { throw new Oops_Sql_Selector_Exception("Unexcepted array", Oops_Sql_Selector_Exception::UnexpectedValueType); } $operands = array(self::CMP_GT => '> ', self::CMP_GE => '>= ', self::CMP_LT => '< ', self::CMP_LE => '<= '); $cond .= $operands[$compare] . Oops_Sql_Common::quoteValue($value); break; case self::CMP_LIKE: Oops_Utils::ToArray($value); if (!count($value)) { $cond = ''; } else { $value = array_map(array('Oops_Sql', 'Escape'), $value); $cond = "({$fid} LIKE '" . join("' OR {$fid} LIKE '", $value) . "')"; } break; case self::CMP_MLIKE: Oops_Utils::ToArray($value); if (!count($value)) { $cond = ''; } else { $value = array_map(array('Oops_Sql', 'Escape'), $value); $cond = "({$fid} LIKE '%" . join("%' OR {$fid} LIKE '%", $value) . "%')"; } break; default: throw new Oops_Sql_Selector_Exception("Unexpected compare type {$compare}", Oops_Sql_Selector_Exception::UnexpectedCompareType); } return $cond; }