Bug #22959 » ux_t3lib_db_add_listQuery.patch
class.ux_t3lib_db.php (Arbeitskopie) | ||
---|---|---|
return $query;
|
||
}
|
||
/**
|
||
* Returns a WHERE clause that can find a value ($value) in a list field ($field)
|
||
* For instance a record in the database might contain a list of numbers,
|
||
* "34,234,5" (with no spaces between). This query would be able to select that
|
||
* record based on the value "34", "234" or "5" regardless of their positioni in
|
||
* the list (left, middle or right).
|
||
* Is nice to look up list-relations to records or files in TYPO3 database tables.
|
||
*
|
||
* @param string Field name
|
||
* @param string Value to find in list
|
||
* @param string Table in which we are searching (for DBAL detection of quoteStr() method)
|
||
* @return string WHERE clause for a query
|
||
*/
|
||
function listQuery($field, $value, $table) {
|
||
$pattern = $this->quoteStr($value, $table);
|
||
$patternForLike = $this->escapeStrForLike($pattern, $table);
|
||
$where = '(' . $field . ' LIKE \'%,' . $patternForLike . ',%\' OR ' .
|
||
$field . ' LIKE \'' . $patternForLike . ',%\' OR ' .
|
||
$field . ' LIKE \'%,' . $patternForLike . '\' OR ' .
|
||
$field . '=\'' . $pattern . '\')';
|
||
return $where;
|
||
}
|
||
/**************************************
|
||
*
|
||
* Functions for quoting table/field names
|