BUG Support for case sensitive searches

Through newly added Database->comparisonClause() API
This commit is contained in:
Ingo Schommer 2012-12-11 01:47:47 +01:00
parent 12e2d69c09
commit fc7a21b567

View File

@ -2030,6 +2030,28 @@ class PostgreSQLDatabase extends SS_Database {
}
}
/**
* Generate a WHERE clause for text matching.
*
* @param String $field Quoted field name
* @param String $value Escaped search. Can include percentage wildcards.
* @param boolean $exact Exact matches or wildcard support.
* @param boolean $negate Negate the clause.
* @param boolean $caseSensitive Enforce case sensitivity if TRUE or FALSE.
* Stick with default collation if set to NULL.
* @return String SQL
*/
public function comparisonClause($field, $value, $exact = false, $negate = false, $caseSensitive = null) {
if($exact && $caseSensitive === null) {
$comp = ($negate) ? '!=' : '=';
} else {
$comp = ($caseSensitive === true) ? 'LIKE' : 'ILIKE';
if($negate) $comp = 'NOT ' . $comp;
}
return sprintf("%s %s '%s'", $field, $comp, $value);
}
/**
* Function to return an SQL datetime expression that can be used with Postgres
* used for querying a datetime in a certain format