- Patch #683736 by c960657: use db_like() where appropriate.

merge-requests/26/head
Dries Buytaert 2010-01-13 23:19:54 +00:00
parent 6a5532a258
commit f60739b033
7 changed files with 13 additions and 14 deletions

View File

@ -462,7 +462,7 @@ class DrupalDatabaseCache implements DrupalCacheInterface {
} }
else { else {
db_delete($this->bin) db_delete($this->bin)
->condition('cid', $cid . '%', 'LIKE') ->condition('cid', db_like($cid) . '%', 'LIKE')
->execute(); ->execute();
} }
} }

View File

@ -1480,12 +1480,12 @@ function _locale_translate_seek() {
// Compute LIKE section. // Compute LIKE section.
switch ($query['translation']) { switch ($query['translation']) {
case 'translated': case 'translated':
$sql_query->condition('t.translation', '%' . $query['string'] . '%', 'LIKE'); $sql_query->condition('t.translation', '%' . db_like($query['string']) . '%', 'LIKE');
$sql_query->orderBy('t.translation', 'DESC'); $sql_query->orderBy('t.translation', 'DESC');
break; break;
case 'untranslated': case 'untranslated':
$sql_query->condition(db_and() $sql_query->condition(db_and()
->condition('s.source', '%' . $query['string'] . '%', 'LIKE') ->condition('s.source', '%' . db_like($query['string']) . '%', 'LIKE')
->isNull('t.translation') ->isNull('t.translation')
); );
$sql_query->orderBy('s.source'); $sql_query->orderBy('s.source');
@ -1493,10 +1493,10 @@ function _locale_translate_seek() {
case 'all' : case 'all' :
default: default:
$condition = db_or() $condition = db_or()
->condition('s.source', '%' . $query['string'] . '%', 'LIKE'); ->condition('s.source', '%' . db_like($query['string']) . '%', 'LIKE');
if ($query['language'] != 'en') { if ($query['language'] != 'en') {
// Only search in translations if the language is not forced to English. // Only search in translations if the language is not forced to English.
$condition->condition('t.translation', '%' . $query['string'] . '%', 'LIKE'); $condition->condition('t.translation', '%' . db_like($query['string']) . '%', 'LIKE');
} }
$sql_query->condition($condition); $sql_query->condition($condition);
break; break;

View File

@ -494,17 +494,17 @@ function field_sql_storage_field_storage_query($field_id, $conditions, $options)
switch ($operator) { switch ($operator) {
case 'STARTS_WITH': case 'STARTS_WITH':
$operator = 'LIKE'; $operator = 'LIKE';
$value .= '%'; $value = db_like($value) . '%';
break; break;
case 'ENDS_WITH': case 'ENDS_WITH':
$operator = 'LIKE'; $operator = 'LIKE';
$value = "$value%"; $value = '%' . db_like($value);
break; break;
case 'CONTAINS': case 'CONTAINS':
$operator = 'LIKE'; $operator = 'LIKE';
$value = "%$value%"; $value = '%' . db_like($value) . '%';
break; break;
} }
// Translate field columns into prefixed db columns. // Translate field columns into prefixed db columns.

View File

@ -53,7 +53,7 @@ function profile_browse() {
$query->condition('v.value', $value); $query->condition('v.value', $value);
break; break;
case 'list': case 'list':
$query->condition('v.value', '%' . $value . '%', 'LIKE'); $query->condition('v.value', '%' . db_like($value) . '%', 'LIKE');
break; break;
default: default:
drupal_not_found(); drupal_not_found();

View File

@ -813,6 +813,7 @@ class TaxonomyTermController extends DrupalDefaultEntityController {
foreach ($conditions as $key => $condition) { foreach ($conditions as $key => $condition) {
if ($condition['field'] == 'base.name') { if ($condition['field'] == 'base.name') {
$conditions[$key]['operator'] = 'LIKE'; $conditions[$key]['operator'] = 'LIKE';
$conditions[$key]['value'] = db_like($conditions[$key]['value']);
} }
} }
} }

View File

@ -102,13 +102,11 @@ function taxonomy_autocomplete($field_name, $tags_typed = '') {
if (!empty($tags_typed)) { if (!empty($tags_typed)) {
$query->condition('t.name', $tags_typed, 'NOT IN'); $query->condition('t.name', $tags_typed, 'NOT IN');
} }
// Select rows that match by term name.
$tags_return = $query $tags_return = $query
->fields('t', array('tid', 'name')) ->fields('t', array('tid', 'name'))
->condition('t.vid', $vids) ->condition('t.vid', $vids)
// Select rows that match by term name. ->condition('t.name', '%' . db_like($tag_last) . '%', 'LIKE')
->condition(db_or()
->where("t.name LIKE :last_string", array(':last_string' => '%' . $tag_last . '%'))
)
->range(0, 10) ->range(0, 10)
->execute() ->execute()
->fetchAllKeyed(); ->fetchAllKeyed();