public static function buildClause($lhs, $op, $rhs, $params = array())
{
switch ($op) {
case 'LIKE':
if (empty($rhs)) {
return '(' . $lhs . '=*)';
}
if (!empty($params['begin'])) {
return sprintf('(|(%s=%s*)(%s=* %s*))', $lhs, self::quote($rhs), $lhs, self::quote($rhs));
}
if (!empty($params['approximate'])) {
return sprintf('(%s~=%s)', $lhs, self::quote($rhs));
}
return sprintf('(%s=*%s*)', $lhs, self::quote($rhs));
default:
return sprintf('(%s%s%s)', $lhs, $op, self::quote($rhs));
}
}