Index: includes/database/query.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/database/query.inc,v retrieving revision 1.41 diff -u -9 -p -r1.41 query.inc --- includes/database/query.inc 6 Feb 2010 19:01:38 -0000 1.41 +++ includes/database/query.inc 28 Feb 2010 17:49:07 -0000 @@ -1326,18 +1326,19 @@ class DatabaseCondition implements Query // $specials does not use drupal_static as its value never changes. static $specials = array( 'BETWEEN' => array('delimiter' => ' AND '), 'IN' => array('delimiter' => ', ', 'prefix' => ' (', 'postfix' => ')'), 'NOT IN' => array('delimiter' => ', ', 'prefix' => ' (', 'postfix' => ')'), 'IS NULL' => array('use_value' => FALSE), '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(), '>' => array(), '>=' => array(), '<=' => array(), ); if (isset($specials[$operator])) { $return = $specials[$operator]; Index: includes/database/pgsql/database.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/database/pgsql/database.inc,v retrieving revision 1.34 diff -u -9 -p -r1.34 database.inc --- includes/database/pgsql/database.inc 12 Feb 2010 06:58:43 -0000 1.34 +++ includes/database/pgsql/database.inc 28 Feb 2010 17:49:07 -0000 @@ -122,18 +122,19 @@ class DatabaseConnection_pgsql extends D return 'pgsql'; } public function mapConditionOperator($operator) { static $specials = array( // In PostgreSQL, 'LIKE' is case-sensitive. For case-insensitive LIKE // 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; } /** * Retrive a the next id in a sequence. * * PostgreSQL has built in sequences. We'll use these instead of inserting Index: includes/database/sqlite/database.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/database/sqlite/database.inc,v retrieving revision 1.25 diff -u -9 -p -r1.25 database.inc --- includes/database/sqlite/database.inc 15 Feb 2010 22:14:17 -0000 1.25 +++ includes/database/sqlite/database.inc 28 Feb 2010 17:49:07 -0000 @@ -151,18 +151,19 @@ class DatabaseConnection_sqlite extends public function databaseType() { return 'sqlite'; } public function mapConditionOperator($operator) { // 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; } public function prepareQuery($query) { return $this->prepare($this->prefixTables($query)); } public function nextId($existing_id = 0) { Index: modules/statistics/statistics.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/statistics/statistics.admin.inc,v retrieving revision 1.38 diff -u -9 -p -r1.38 statistics.admin.inc --- modules/statistics/statistics.admin.inc 26 Jan 2010 08:19:45 -0000 1.38 +++ modules/statistics/statistics.admin.inc 28 Feb 2010 17:49:07 -0000 @@ -154,28 +154,28 @@ function statistics_top_referrers() { array('data' => t('Url'), 'field' => 'url'), array('data' => t('Last visit'), 'field' => 'last'), ); $query = db_select('accesslog', 'a')->extend('PagerDefault')->extend('TableSort'); $query->addExpression('COUNT(url)', 'hits'); $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) ->orderByHeader($header); $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); $result = $query->execute(); $rows = array(); foreach ($result as $referrer) { $rows[] = array($referrer->hits, _statistics_link($referrer->url), t('@time ago', array('@time' => format_interval(REQUEST_TIME - $referrer->last)))); } Index: modules/system/system.install =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.install,v retrieving revision 1.449 diff -u -9 -p -r1.449 system.install --- modules/system/system.install 26 Feb 2010 06:39:13 -0000 1.449 +++ modules/system/system.install 28 Feb 2010 17:49:07 -0000 @@ -1758,19 +1758,19 @@ function system_update_7003() { } // Make sure not to block any IP addresses that were specifically allowed by access rules. if (!empty($result)) { $result = db_query("SELECT mask FROM {access} WHERE status = :status AND type = :type", array( ':status' => 1, ':type' => $type, )); $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') ->condition($or) ->execute(); } } } Index: modules/user/user.module =================================================================== RCS file: /cvs/drupal/drupal/modules/user/user.module,v retrieving revision 1.1128 diff -u -9 -p -r1.1128 user.module --- modules/user/user.module 26 Feb 2010 16:55:18 -0000 1.1128 +++ modules/user/user.module 28 Feb 2010 17:49:08 -0000 @@ -850,23 +850,23 @@ function user_search_access() { function user_search_execute($keys = NULL) { $find = array(); // Replace wildcards with MySQL/PostgreSQL wildcards. $keys = preg_replace('!\*+!', '%', $keys); $query = db_select('users')->extend('PagerDefault'); $query->fields('users', array('name', 'uid', 'mail')); 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) ->execute(); foreach ($result as $account) { $find[] = array('title' => $account->name . ' (' . $account->mail . ')', 'link' => url('user/' . $account->uid, array('absolute' => TRUE))); } return $find; } @@ -1119,19 +1119,19 @@ function user_account_form_validate($for elseif ((bool) db_select('users')->fields('users', array('uid'))->condition('uid', $account->uid, '<>')->condition('name', db_like($form_state['values']['name']), 'LIKE')->range(0, 1)->execute()->fetchField()) { form_set_error('name', t('The name %name is already taken.', array('%name' => $form_state['values']['name']))); } } // Validate the e-mail address, and check if it is taken by an existing user. 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']))); } else { form_set_error('mail', t('The e-mail address %email is already registered. Have you forgotten your password?', array('%email' => $form_state['values']['mail'], '@password' => url('user/password')))); } } Index: modules/user/user.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/user/user.pages.inc,v retrieving revision 1.67 diff -u -9 -p -r1.67 user.pages.inc --- modules/user/user.pages.inc 17 Feb 2010 05:42:42 -0000 1.67 +++ modules/user/user.pages.inc 28 Feb 2010 17:49:08 -0000 @@ -6,19 +6,19 @@ * User page callback file for the user module. */ /** * Menu callback; Retrieve a JSON object containing autocomplete suggestions for existing users. */ 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); } } drupal_json_output($matches); } /**