diff options
-rw-r--r-- | includes/database/pgsql/database.inc | 1 | ||||
-rw-r--r-- | includes/database/query.inc | 1 | ||||
-rw-r--r-- | includes/database/sqlite/database.inc | 1 | ||||
-rw-r--r-- | modules/statistics/statistics.admin.inc | 4 | ||||
-rw-r--r-- | modules/system/system.install | 2 | ||||
-rw-r--r-- | modules/user/user.module | 8 | ||||
-rw-r--r-- | modules/user/user.pages.inc | 2 |
7 files changed, 11 insertions, 8 deletions
diff --git a/includes/database/pgsql/database.inc b/includes/database/pgsql/database.inc index 841be2296..f76fd95ee 100644 --- a/includes/database/pgsql/database.inc +++ b/includes/database/pgsql/database.inc @@ -128,6 +128,7 @@ class DatabaseConnection_pgsql extends DatabaseConnection { // statements, we need to use ILIKE instead. Use backslash for escaping // wildcard characters. 'LIKE' => array('operator' => 'ILIKE', 'postfix' => " ESCAPE '\\\\'"), + 'NOT LIKE' => array('operator' => 'NOT ILIKE', 'postfix' => " ESCAPE '\\\\'"), ); return isset($specials[$operator]) ? $specials[$operator] : NULL; diff --git a/includes/database/query.inc b/includes/database/query.inc index 0b03783f5..ff591f04c 100644 --- a/includes/database/query.inc +++ b/includes/database/query.inc @@ -1332,6 +1332,7 @@ class DatabaseCondition implements QueryConditionInterface, Countable { 'IS NOT NULL' => array('use_value' => FALSE), // Use backslash for escaping wildcard characters. 'LIKE' => array('postfix' => " ESCAPE '\\\\'"), + 'NOT LIKE' => array('postfix' => " ESCAPE '\\\\'"), // These ones are here for performance reasons. '=' => array(), '<' => array(), diff --git a/includes/database/sqlite/database.inc b/includes/database/sqlite/database.inc index af20b10be..5889fafe7 100644 --- a/includes/database/sqlite/database.inc +++ b/includes/database/sqlite/database.inc @@ -157,6 +157,7 @@ class DatabaseConnection_sqlite extends DatabaseConnection { // We don't want to override any of the defaults. static $specials = array( 'LIKE' => array('postfix' => " ESCAPE '\\'"), + 'NOT LIKE' => array('postfix' => " ESCAPE '\\'"), ); return isset($specials[$operator]) ? $specials[$operator] : NULL; } diff --git a/modules/statistics/statistics.admin.inc b/modules/statistics/statistics.admin.inc index 303eafa44..b9e986b85 100644 --- a/modules/statistics/statistics.admin.inc +++ b/modules/statistics/statistics.admin.inc @@ -160,7 +160,7 @@ function statistics_top_referrers() { $query->addExpression('MAX(timestamp)', 'last'); $query ->fields('a', array('url')) - ->where('LOWER(url) NOT LIKE :host', array(':host' => '%' . $_SERVER['HTTP_HOST'] . '%')) + ->condition('url', '%' . $_SERVER['HTTP_HOST'] . '%', 'NOT LIKE') ->condition('url', '', '<>') ->groupBy('url') ->limit(30) @@ -169,7 +169,7 @@ function statistics_top_referrers() { $count_query = db_select('accesslog', 'a', array('target' => 'slave')); $count_query->addExpression('COUNT(DISTINCT url)'); $count_query - ->where('LOWER(url) NOT LIKE :host', array(':host' => '%' . $_SERVER['HTTP_HOST'] . '%')) + ->condition('url', '%' . $_SERVER['HTTP_HOST'] . '%', 'NOT LIKE') ->condition('url', '', '<>'); $query->setCountQuery($count_query); diff --git a/modules/system/system.install b/modules/system/system.install index c414d99b1..ccdcad65c 100644 --- a/modules/system/system.install +++ b/modules/system/system.install @@ -1764,7 +1764,7 @@ function system_update_7003() { )); $or = db_condition('or'); foreach ($result as $allowed) { - $or->where('LOWER(ip) LIKE LOWER(:mask)', array(':mask' => $allowed->mask)); + $or->condition('ip', $allowed->mask, 'LIKE'); } if (count($or)) { db_delete('blocked_ips') diff --git a/modules/user/user.module b/modules/user/user.module index 0d3fced7f..21398fa0b 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -856,11 +856,11 @@ function user_search_execute($keys = NULL) { if (user_access('administer users')) { // Administrators can also search in the otherwise private email field. $query->condition(db_or()-> - where('LOWER(name) LIKE LOWER(:name)', array(':name' => "%$keys%"))-> - where('LOWER(mail) LIKE LOWER(:mail)', array(':mail' => "%$keys%"))); + condition('name', '%' . db_like($keys) . '%', 'LIKE')-> + condition('mail', '%' . db_like($keys) . '%', 'LIKE')); } else { - $query->where('LOWER(name) LIKE LOWER(:name)', array(':name' => "%$keys%")); + $query->condition('name', '%' . db_like($keys) . '%', 'LIKE'); } $result = $query ->limit(15) @@ -1125,7 +1125,7 @@ function user_account_form_validate($form, &$form_state) { if ($error = user_validate_mail($form_state['values']['mail'])) { form_set_error('mail', $error); } - elseif ((bool) db_query_range("SELECT 1 FROM {users} WHERE uid <> :uid AND LOWER(mail) = LOWER(:mail)", 0, 1, array(':uid' => $account->uid, ':mail' => $form_state['values']['mail']))->fetchField()) { + elseif ((bool) db_select('users')->fields('users', array('uid'))->condition('uid', $account->uid, '<>')->condition('mail', db_like($form_state['values']['mail']), 'LIKE')->range(0, 1)->execute()->fetchField()) { // Format error message dependent on whether the user is logged in or not. if ($GLOBALS['user']->uid) { form_set_error('mail', t('The e-mail address %email is already taken.', array('%email' => $form_state['values']['mail']))); diff --git a/modules/user/user.pages.inc b/modules/user/user.pages.inc index 4d2a575f6..7f40eadd6 100644 --- a/modules/user/user.pages.inc +++ b/modules/user/user.pages.inc @@ -12,7 +12,7 @@ function user_autocomplete($string = '') { $matches = array(); if ($string) { - $result = db_query_range("SELECT name FROM {users} WHERE LOWER(name) LIKE LOWER(:name)", 0, 10, array(':name' => $string . '%')); + $result = db_select('users')->fields('users', array('name'))->condition('name', db_like($string) . '%', 'LIKE')->range(0, 10)->execute(); foreach ($result as $user) { $matches[$user->name] = check_plain($user->name); } |