summaryrefslogtreecommitdiff
path: root/modules/node/node.module
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/node/node.module
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/node/node.module')
-rw-r--r--modules/node/node.module6
1 files changed, 3 insertions, 3 deletions
diff --git a/modules/node/node.module b/modules/node/node.module
index 55939b2c8..b6f6069b3 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -555,7 +555,7 @@ function node_types_rebuild() {
function node_type_save($info) {
$is_existing = FALSE;
$existing_type = !empty($info->old_type) ? $info->old_type : $info->type;
- $is_existing = db_query("SELECT COUNT(*) FROM {node_type} WHERE type = :type", array(':type' => $existing_type))->fetchField();
+ $is_existing = (bool) db_query_range('SELECT 1 FROM {node_type} WHERE type = :type', array(':type' => $existing_type), 0, 1)->fetchField();
$type = node_type_set_defaults($info);
$fields = array(
@@ -3085,8 +3085,8 @@ function node_assign_owner_action_form($context) {
}
function node_assign_owner_action_validate($form, $form_state) {
- $count = db_query('SELECT COUNT(*) FROM {users} WHERE name = :name', array(':name' => $form_state['values']['owner_name']))->fetchField();
- if (intval($count) != 1) {
+ $exists = (bool) db_query_range('SELECT 1 FROM {users} WHERE name = :name', array(':name' => $form_state['values']['owner_name']), 0, 1)->fetchField();
+ if (!$exists) {
form_set_error('owner_name', t('Please enter a valid username.'));
}
}