summaryrefslogtreecommitdiff
path: root/modules/profile
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2009-05-16 15:23:16 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2009-05-16 15:23:16 +0000
commitf577c125e84bc3a1f30bcc40105788d0547a534a (patch)
tree87654a9fbf162a10ffcb21c4c32289743687b8cd /modules/profile
parent8b63d832de0c708836393bdf83fffe8bf10c2a3f (diff)
downloadbrdo-f577c125e84bc3a1f30bcc40105788d0547a534a.tar.gz
brdo-f577c125e84bc3a1f30bcc40105788d0547a534a.tar.bz2
#196862 by Damien Tournoud, et al: Replace COUNT(*) queries with SELECT 1 ... LIMIT 1 queries when all that's required is a check for whether rows exist.
Diffstat (limited to 'modules/profile')
-rw-r--r--modules/profile/profile.module3
-rw-r--r--modules/profile/profile.pages.inc3
2 files changed, 4 insertions, 2 deletions
diff --git a/modules/profile/profile.module b/modules/profile/profile.module
index 919910746..893e63dad 100644
--- a/modules/profile/profile.module
+++ b/modules/profile/profile.module
@@ -511,7 +511,8 @@ function profile_category_access($account, $category) {
return TRUE;
}
else {
- return user_edit_access($account) && db_result(db_query("SELECT COUNT(*) FROM {profile_field} WHERE category = '%s' AND visibility <> %d", $category, PROFILE_HIDDEN));
+ $category_visible = (bool) db_query_range('SELECT 1 FROM {profile_field} WHERE category = :category AND visibility <> :visibility', array(':category' => $category, ':visibility' => PROFILE_HIDDEN), 0, 1)->fetchField();
+ return user_edit_access($account) && $category_visible;
}
}
diff --git a/modules/profile/profile.pages.inc b/modules/profile/profile.pages.inc
index 788e2de61..858458eb1 100644
--- a/modules/profile/profile.pages.inc
+++ b/modules/profile/profile.pages.inc
@@ -110,7 +110,8 @@ function profile_browse() {
*/
function profile_autocomplete($field, $string) {
$matches = array();
- if (db_result(db_query("SELECT COUNT(*) FROM {profile_field} WHERE fid = %d AND autocomplete = 1", $field))) {
+ $autocomplete_field = (bool) db_query_range("SELECT 1 FROM {profile_field} WHERE fid = :fid AND autocomplete = 1", array(':fid' => $field), 0, 1)->fetchField();
+ if ($autocomplete_field) {
$result = db_query_range("SELECT value FROM {profile_value} WHERE fid = :fid AND LOWER(value) LIKE LOWER(:value) GROUP BY value ORDER BY value ASC", array(
':fid' => $field,
':value' => $string .'%',