Project

General

Profile

Bug #22959 » bug_14818_2.patch

Administrator Admin, 2010-07-04 11:05

View differences:

t3lib/class.t3lib_db.php (working copy)
* 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
* record based on the value "34", "234" or "5" regardless of their position in
* the list (left, middle or right).
* The value must not contain a comma (,)
* Is nice to look up list-relations to records or files in TYPO3 database tables.
*
* @param string Field name
......
* @return string WHERE clause for a query
*/
function listQuery($field, $value, $table) {
if (strpos(',', $value) !== false) {
throw new InvalidArgumentException('$value must not contain a comma (,) in $this->listQuery() !');
}
$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 . '\')';
$where = 'find_in_set(\'' . $pattern . '\',' . $field . ') != 0';
return $where;
}
typo3/sysext/dbal/class.ux_t3lib_db.php (working copy)
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 position 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
(4-4/4)