diff -urpN drupal-6.x-dev-200707302333/includes/common.inc drupal-6.x-dev-rmnumrow-0.1/includes/common.inc
--- drupal-6.x-dev-200707302333/includes/common.inc	2007-07-30 01:28:23.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.1/includes/common.inc	2007-07-31 01:13:03.000000000 +0800
@@ -807,7 +807,7 @@ function flood_register_event($name) {
  *   True if the user did not exceed the hourly threshold. False otherwise.
  */
 function flood_is_allowed($name, $threshold) {
-  $number = db_num_rows(db_query("SELECT event FROM {flood} WHERE event = '%s' AND hostname = '%s' AND timestamp > %d", $name, ip_address(), time() - 3600));
+  $number = db_result(db_query("SELECT COUNT(event) FROM {flood} WHERE event = '%s' AND hostname = '%s' AND timestamp > %d", $name, ip_address(), time() - 3600));
   return ($number < $threshold ? TRUE : FALSE);
 }
 
diff -urpN drupal-6.x-dev-200707302333/includes/database.mysqli.inc drupal-6.x-dev-rmnumrow-0.1/includes/database.mysqli.inc
--- drupal-6.x-dev-200707302333/includes/database.mysqli.inc	2007-07-23 16:05:14.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.1/includes/database.mysqli.inc	2007-07-31 02:19:08.000000000 +0800
@@ -190,20 +190,6 @@ function db_fetch_array($result) {
 }
 
 /**
- * Determine how many result rows were found by the preceding query.
- *
- * @param $result
- *   A database query result resource, as returned from db_query().
- * @return
- *   The number of result rows.
- */
-function db_num_rows($result) {
-  if ($result) {
-    return mysqli_num_rows($result);
-  }
-}
-
-/**
 * Return an individual result field from the previous query.
 *
 * Only use this function if exactly one field is being selected; otherwise,
@@ -294,9 +280,8 @@ function db_query_range($query) {
  * so that they can be properly escaped to avoid SQL injection attacks.
  *
  * Note that if you need to know how many results were returned, you should do
- * a SELECT COUNT(*) on the temporary table afterwards. db_num_rows() and
- * db_affected_rows() do not give consistent result across different database
- * types in this case.
+ * a SELECT COUNT(*) on the temporary table afterwards. db_affected_rows() do
+ * not give consistent result across different database types in this case.
  *
  * @param $query
  *   A string containing a normal SELECT SQL query.
@@ -382,14 +367,14 @@ function db_unlock_tables() {
  * Check if a table exists.
  */
 function db_table_exists($table) {
-  return db_num_rows(db_query("SHOW TABLES LIKE '{". db_escape_table($table) ."}'"));
+  return db_fetch_object(db_query("SHOW TABLES LIKE '{". db_escape_table($table) ."}'")) ? TRUE : FALSE;
 }
 
 /**
  * Check if a column exists in the given table.
  */
 function db_column_exists($table, $column) {
-  return db_num_rows(db_query("SHOW COLUMNS FROM {%s} LIKE '%s'", $table, $column));
+  return db_fetch_object(db_query("SHOW COLUMNS FROM {%s} LIKE '%s'", $table, $column)) ? TRUE : FALSE;
 }
 
 /**
diff -urpN drupal-6.x-dev-200707302333/includes/database.mysql.inc drupal-6.x-dev-rmnumrow-0.1/includes/database.mysql.inc
--- drupal-6.x-dev-200707302333/includes/database.mysql.inc	2007-07-23 16:05:14.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.1/includes/database.mysql.inc	2007-07-31 02:20:41.000000000 +0800
@@ -191,20 +191,6 @@ function db_fetch_array($result) {
 }
 
 /**
- * Determine how many result rows were found by the preceding query.
- *
- * @param $result
- *   A database query result resource, as returned from db_query().
- * @return
- *   The number of result rows.
- */
-function db_num_rows($result) {
-  if ($result) {
-    return mysql_num_rows($result);
-  }
-}
-
-/**
  * Return an individual result field from the previous query.
  *
  * Only use this function if exactly one field is being selected; otherwise,
@@ -294,9 +280,8 @@ function db_query_range($query) {
  * so that they can be properly escaped to avoid SQL injection attacks.
  *
  * Note that if you need to know how many results were returned, you should do
- * a SELECT COUNT(*) on the temporary table afterwards. db_num_rows() and
- * db_affected_rows() do not give consistent result across different database
- * types in this case.
+ * a SELECT COUNT(*) on the temporary table afterwards. db_affected_rows() do
+ * not give consistent result across different database types in this case.
  *
  * @param $query
  *   A string containing a normal SELECT SQL query.
@@ -382,14 +367,14 @@ function db_unlock_tables() {
  * Check if a table exists.
  */
 function db_table_exists($table) {
-  return db_num_rows(db_query("SHOW TABLES LIKE '{". db_escape_table($table) ."}'"));
+  return db_fetch_object(db_query("SHOW TABLES LIKE '{". db_escape_table($table) ."}'")) ? TRUE : FALSE;
 }
 
 /**
  * Check if a column exists in the given table.
  */
 function db_column_exists($table, $column) {
-  return db_num_rows(db_query("SHOW COLUMNS FROM {%s} LIKE '%s'", $table, $column));
+  return db_fetch_object(db_query("SHOW COLUMNS FROM {%s} LIKE '%s'", $table, $column)) ? TRUE : FALSE;
 }
 
 /**
diff -urpN drupal-6.x-dev-200707302333/includes/database.pgsql.inc drupal-6.x-dev-rmnumrow-0.1/includes/database.pgsql.inc
--- drupal-6.x-dev-200707302333/includes/database.pgsql.inc	2007-07-23 16:05:14.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.1/includes/database.pgsql.inc	2007-07-31 02:21:45.000000000 +0800
@@ -208,20 +208,6 @@ function db_fetch_array($result) {
 }
 
 /**
- * Determine how many result rows were found by the preceding query.
- *
- * @param $result
- *   A database query result resource, as returned from db_query().
- * @return
- *   The number of result rows.
- */
-function db_num_rows($result) {
-  if ($result) {
-    return pg_num_rows($result);
-  }
-}
-
-/**
  * Return an individual result field from the previous query.
  *
  * Only use this function if exactly one field is being selected; otherwise,
@@ -326,9 +312,8 @@ function db_query_range($query) {
  * so that they can be properly escaped to avoid SQL injection attacks.
  *
  * Note that if you need to know how many results were returned, you should do
- * a SELECT COUNT(*) on the temporary table afterwards. db_num_rows() and
- * db_affected_rows() do not give consistent result across different database
- * types in this case.
+ * a SELECT COUNT(*) on the temporary table afterwards. db_affected_rows() do
+ * not give consistent result across different database types in this case.
  *
  * @param $query
  *   A string containing a normal SELECT SQL query.
@@ -417,7 +402,7 @@ function db_unlock_tables() {
  * Check if a table exists.
  */
 function db_table_exists($table) {
-  return db_num_rows(db_query("SELECT relname FROM pg_class WHERE relname = '{". db_escape_table($table) ."}'"));
+  return db_result(db_query("SELECT COUNT(relname) FROM pg_class WHERE relname = '{". db_escape_table($table) ."}'"));
 }
 
 /**
diff -urpN drupal-6.x-dev-200707302333/includes/locale.inc drupal-6.x-dev-rmnumrow-0.1/includes/locale.inc
--- drupal-6.x-dev-200707302333/includes/locale.inc	2007-07-21 17:26:07.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.1/includes/locale.inc	2007-07-31 01:14:47.000000000 +0800
@@ -282,7 +282,7 @@ function _locale_languages_common_contro
 function locale_languages_predefined_form_validate($form, &$form_state) {
   $langcode = $form_state['values']['langcode'];
 
-  if ($duplicate = db_num_rows(db_query("SELECT language FROM {languages} WHERE language = '%s'", $langcode)) != 0) {
+  if ($duplicate = db_result(db_query("SELECT COUNT(language) FROM {languages} WHERE language = '%s'", $langcode)) != 0) {
     form_set_error('langcode', t('The language %language (%code) already exists.', array('%language' => $form_state['values']['name'], '%code' => $langcode)));
   }
 
diff -urpN drupal-6.x-dev-200707302333/includes/menu.inc drupal-6.x-dev-rmnumrow-0.1/includes/menu.inc
--- drupal-6.x-dev-200707302333/includes/menu.inc	2007-07-25 22:44:03.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.1/includes/menu.inc	2007-07-31 01:10:27.000000000 +0800
@@ -716,11 +716,12 @@ function menu_tree_page_data($menu_name 
             // their children to the list as well.
             do {
               $result = db_query("SELECT mlid FROM {menu_links} WHERE expanded != 0 AND has_children != 0 AND menu_name = '%s' AND plid IN (". $placeholders .') AND mlid NOT IN ('. $placeholders .')', array_merge(array($menu_name), $args, $args));
+              $item = NULL;
               while ($item = db_fetch_array($result)) {
                 $args[] = $item['mlid'];
               }
               $placeholders = implode(', ', array_fill(0, count($args), '%d'));
-            } while (db_num_rows($result));
+            } while ($item);
           }
           array_unshift($args, $menu_name);
         }
diff -urpN drupal-6.x-dev-200707302333/includes/session.inc drupal-6.x-dev-rmnumrow-0.1/includes/session.inc
--- drupal-6.x-dev-200707302333/includes/session.inc	2007-07-23 15:29:29.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.1/includes/session.inc	2007-07-31 01:13:48.000000000 +0800
@@ -61,9 +61,9 @@ function sess_write($key, $value) {
     return TRUE;
   }
 
-  $result = db_query("SELECT sid FROM {sessions} WHERE sid = '%s'", $key);
+  $result = db_result(db_query("SELECT COUNT(sid) FROM {sessions} WHERE sid = '%s'", $key));
 
-  if (!db_num_rows($result)) {
+  if (!$result) {
     // Only save session data when when the browser sends a cookie. This keeps
     // crawlers out of session table. This reduces memory and server load,
     // and gives more useful statistics. We can't eliminate anonymous session
diff -urpN drupal-6.x-dev-200707302333/modules/aggregator/aggregator.module drupal-6.x-dev-rmnumrow-0.1/modules/aggregator/aggregator.module
--- drupal-6.x-dev-200707302333/modules/aggregator/aggregator.module	2007-07-16 20:43:04.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.1/modules/aggregator/aggregator.module	2007-07-31 02:39:15.000000000 +0800
@@ -963,11 +963,10 @@ function aggregator_parse_feed(&$data, $
   $age = time() - variable_get('aggregator_clear', 9676800);
   $result = db_query('SELECT iid FROM {aggregator_item} WHERE fid = %d AND timestamp < %d', $feed['fid'], $age);
 
-  if (db_num_rows($result)) {
-    $items = array();
-    while ($item = db_fetch_object($result)) {
-      $items[] = $item->iid;
-    }
+  while ($item = db_fetch_object($result)) {
+    $items[] = $item->iid;
+  }
+  if (count($items)) {
     db_query('DELETE FROM {aggregator_category_item} WHERE iid IN ('. implode(', ', $items) .')');
     db_query('DELETE FROM {aggregator_item} WHERE fid = %d AND timestamp < %d', $feed['fid'], $age);
   }
diff -urpN drupal-6.x-dev-200707302333/modules/block/block.admin.inc drupal-6.x-dev-rmnumrow-0.1/modules/block/block.admin.inc
--- drupal-6.x-dev-200707302333/modules/block/block.admin.inc	2007-07-25 02:17:30.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.1/modules/block/block.admin.inc	2007-07-31 01:22:33.000000000 +0800
@@ -219,7 +219,7 @@ function block_admin_configure(&$form_st
 
 function block_admin_configure_validate($form, &$form_state) {
   if ($form_state['values']['module'] == 'block') {
-    if (empty($form_state['values']['info']) || db_num_rows(db_query("SELECT bid FROM {boxes} WHERE bid != %d AND info = '%s'", $form_state['values']['delta'], $form_state['values']['info']))) {
+    if (empty($form_state['values']['info']) || db_result(db_query("SELECT COUNT(bid) FROM {boxes} WHERE bid != %d AND info = '%s'", $form_state['values']['delta'], $form_state['values']['info']))) {
       form_set_error('info', t('Please ensure that each block description is unique.'));
     }
   }
@@ -248,7 +248,7 @@ function block_add_block_form(&$form_sta
 }
 
 function block_add_block_form_validate($form, &$form_state) {
-  if (empty($form_state['values']['info']) || db_num_rows(db_query("SELECT info FROM {boxes} WHERE info = '%s'", $form_state['values']['info']))) {
+  if (empty($form_state['values']['info']) || db_result(db_query("SELECT COUNT(info) FROM {boxes} WHERE info = '%s'", $form_state['values']['info']))) {
     form_set_error('info', t('Please ensure that each block description is unique.'));
   }
 }
diff -urpN drupal-6.x-dev-200707302333/modules/blog/blog.module drupal-6.x-dev-rmnumrow-0.1/modules/blog/blog.module
--- drupal-6.x-dev-200707302333/modules/blog/blog.module	2007-07-22 14:48:25.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.1/modules/blog/blog.module	2007-07-31 01:19:56.000000000 +0800
@@ -192,8 +192,9 @@ function blog_block($op = 'list', $delta
   else if ($op == 'view') {
     if (user_access('access content')) {
       $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC"), 0, 10);
-      if (db_num_rows($result)) {
-        $block['content'] = node_title_list($result);
+      $node_title_list = node_title_list($result);
+      if ($node_title_list) {
+        $block['content'] = $node_title_list;
         $block['content'] .= '<div class="more-link">'. l(t('more'), 'blog', array('title' => t('Read the latest blog entries.'))) .'</div>';
         $block['subject'] = t('Recent blog posts');
         return $block;
diff -urpN drupal-6.x-dev-200707302333/modules/book/book.module drupal-6.x-dev-rmnumrow-0.1/modules/book/book.module
--- drupal-6.x-dev-200707302333/modules/book/book.module	2007-07-04 03:29:32.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.1/modules/book/book.module	2007-07-31 01:45:36.000000000 +0800
@@ -169,9 +169,7 @@ function book_block($op = 'list', $delta
     // Only display this block when the user is browsing a book:
     if (arg(0) == 'node' && is_numeric(arg(1))) {
       $result = db_query(db_rewrite_sql('SELECT n.nid, n.title, b.parent FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE n.nid = %d'), arg(1));
-      if (db_num_rows($result) > 0) {
-        $node = db_fetch_object($result);
-
+      if ($node = db_fetch_object($result)) {
         $path = book_location($node);
         $path[] = $node;
 
@@ -643,9 +641,7 @@ function book_render() {
 function book_export($type, $nid) {
   $type = drupal_strtolower($type);
   $node_result = db_query(db_rewrite_sql('SELECT n.nid, n.title, b.parent FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE n.nid = %d'), $nid);
-  if (db_num_rows($node_result) > 0) {
-      $node = db_fetch_object($node_result);
-  }
+  $node = db_fetch_object($node_result);
   $depth = count(book_location($node)) + 1;
   $export_function = 'book_export_'. $type;
 
diff -urpN drupal-6.x-dev-200707302333/modules/comment/comment.module drupal-6.x-dev-rmnumrow-0.1/modules/comment/comment.module
--- drupal-6.x-dev-200707302333/modules/comment/comment.module	2007-07-25 22:57:58.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.1/modules/comment/comment.module	2007-07-31 02:07:28.000000000 +0800
@@ -1024,12 +1024,10 @@ function comment_render($node, $cid = 0)
 
       // Start a form, for use with comment control.
       $result = pager_query($query, $comments_per_page, 0, $query_count, $query_args);
-      if (db_num_rows($result) && (variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE || variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE_BELOW)) {
-        $output .= drupal_get_form('comment_controls', $mode, $order, $comments_per_page);
-      }
 
       $divs = 0;
       $last_depth = 0;
+      $comments = '';
       drupal_add_css(drupal_get_path('module', 'comment') .'/comment.css');
       while ($comment = db_fetch_object($result)) {
         $comment = drupal_unpack($comment);
@@ -1039,37 +1037,43 @@ function comment_render($node, $cid = 0)
         if ($mode == COMMENT_MODE_THREADED_COLLAPSED || $mode == COMMENT_MODE_THREADED_EXPANDED) {
           if ($comment->depth > $last_depth) {
             $divs++;
-            $output .= '<div class="indented">';
+            $comments .= '<div class="indented">';
             $last_depth++;
           }
           else {
             while ($comment->depth < $last_depth) {
               $divs--;
-              $output .= '</div>';
+              $comments .= '</div>';
               $last_depth--;
             }
           }
         }
 
         if ($mode == COMMENT_MODE_FLAT_COLLAPSED) {
-          $output .= theme('comment_flat_collapsed', $comment, $node);
+          $comments .= theme('comment_flat_collapsed', $comment, $node);
         }
         else if ($mode == COMMENT_MODE_FLAT_EXPANDED) {
-          $output .= theme('comment_flat_expanded', $comment, $node);
+          $comments .= theme('comment_flat_expanded', $comment, $node);
         }
         else if ($mode == COMMENT_MODE_THREADED_COLLAPSED) {
-          $output .= theme('comment_thread_collapsed', $comment, $node);
+          $comments .= theme('comment_thread_collapsed', $comment, $node);
         }
         else if ($mode == COMMENT_MODE_THREADED_EXPANDED) {
-          $output .= theme('comment_thread_expanded', $comment, $node);
+          $comments .= theme('comment_thread_expanded', $comment, $node);
         }
       }
+
+      if ($comments && (variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE || variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE_BELOW)) {
+        $output .= drupal_get_form('comment_controls', $mode, $order, $comments_per_page);
+      }
+      $output .= $comments;
+
       for ($i = 0; $i < $divs; $i++) {
         $output .= '</div>';
       }
       $output .= theme('pager', NULL, $comments_per_page, 0);
 
-      if (db_num_rows($result) && (variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_BELOW || variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE_BELOW)) {
+      if ($comments && (variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_BELOW || variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE_BELOW)) {
         $output .= drupal_get_form('comment_controls', $mode, $order, $comments_per_page);
       }
     }
diff -urpN drupal-6.x-dev-200707302333/modules/drupal/drupal.module drupal-6.x-dev-rmnumrow-0.1/modules/drupal/drupal.module
--- drupal-6.x-dev-200707302333/modules/drupal/drupal.module	2007-07-01 03:46:55.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.1/modules/drupal/drupal.module	2007-07-31 01:28:41.000000000 +0800
@@ -251,8 +251,7 @@ function drupal_client_ping($client, $sy
 
   if ($client['link'] && $client['name'] && $client['mail'] && $client['slogan'] && $client['mission']) {
     $result = db_query("SELECT cid FROM {client} WHERE link = '%s'", $client['link']);
-    if (db_num_rows($result)) {
-      $record = db_fetch_object($result);
+    if ($record = db_fetch_object($result)) {
       $client['cid'] = $record->cid;
       // We have an existing record.
       db_query("UPDATE {client} SET link = '%s', name = '%s', mail = '%s', slogan = '%s', mission = '%s', users = %d, nodes = %d, version = '%s', changed = '%s' WHERE cid = %d", $client['uid'], $client['link'], $client['name'], $client['mail'], $client['slogan'], $client['mission'], $client['users'], $client['nodes'], $client['version'], time(), $client['cid']);
diff -urpN drupal-6.x-dev-200707302333/modules/forum/forum.module drupal-6.x-dev-rmnumrow-0.1/modules/forum/forum.module
--- drupal-6.x-dev-200707302333/modules/forum/forum.module	2007-07-26 14:48:03.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.1/modules/forum/forum.module	2007-07-31 01:55:35.000000000 +0800
@@ -375,18 +375,14 @@ function forum_block($op = 'list', $delt
             $title = t('Active forum topics');
             $sql = db_rewrite_sql("SELECT n.nid, n.title, l.comment_count, l.last_comment_timestamp FROM {node} n INNER JOIN {term_node} tn ON tn.nid = n.nid INNER JOIN {term_data} td ON td.tid = tn.tid INNER JOIN {node_comment_statistics} l ON n.nid = l.nid WHERE n.status = 1 AND td.vid = %d ORDER BY l.last_comment_timestamp DESC");
             $result = db_query_range($sql, variable_get('forum_nav_vocabulary', ''), 0, variable_get('forum_block_num_0', '5'));
-            if (db_num_rows($result)) {
-              $content = node_title_list($result);
-            }
+            $content = node_title_list($result);
             break;
 
           case 1:
             $title = t('New forum topics');
             $sql = db_rewrite_sql("SELECT n.nid, n.title, l.comment_count FROM {node} n INNER JOIN {term_node} tn ON tn.nid = n.nid INNER JOIN {term_data} td ON td.tid = tn.tid INNER JOIN {node_comment_statistics} l ON n.nid = l.nid WHERE n.status = 1 AND td.vid = %d ORDER BY n.nid DESC");
             $result = db_query_range($sql, variable_get('forum_nav_vocabulary', ''), 0, variable_get('forum_block_num_1', '5'));
-            if (db_num_rows($result)) {
-              $content = node_title_list($result);
-            }
+            $content = node_title_list($result);
             break;
         }
 
diff -urpN drupal-6.x-dev-200707302333/modules/node/content_types.inc drupal-6.x-dev-rmnumrow-0.1/modules/node/content_types.inc
--- drupal-6.x-dev-200707302333/modules/node/content_types.inc	2007-07-02 01:41:15.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.1/modules/node/content_types.inc	2007-07-31 01:27:25.000000000 +0800
@@ -385,7 +385,7 @@ function node_type_delete_confirm(&$form
   $message = t('Are you sure you want to delete the content type %type?', array('%type' => $type->name));
   $caption = '';
 
-  $num_nodes = db_num_rows(db_query("SELECT * FROM {node} WHERE type = '%s'", $type->type));
+  $num_nodes = db_result(db_query("SELECT COUNT(*) FROM {node} WHERE type = '%s'", $type->type));
   if ($num_nodes) {
     $caption .= '<p>'. format_plural($num_nodes, '<strong>Warning:</strong> there is currently 1 %type post on your site. It may not be able to be displayed or edited correctly, once you have removed this content type.', '<strong>Warning:</strong> there are currently @count %type posts on your site. They may not be able to be displayed or edited correctly, once you have removed this content type.', array('%type' => $type->name)) .'</p>';
   }
diff -urpN drupal-6.x-dev-200707302333/modules/node/node.module drupal-6.x-dev-rmnumrow-0.1/modules/node/node.module
--- drupal-6.x-dev-200707302333/modules/node/node.module	2007-07-27 21:07:06.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.1/modules/node/node.module	2007-07-31 01:08:32.000000000 +0800
@@ -376,7 +376,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_num_rows(db_query("SELECT * FROM {node_type} WHERE type = '%s'", $existing_type));
+  $is_existing = db_result(db_query("SELECT COUNT(*) FROM {node_type} WHERE type = '%s'", $existing_type));
   if (!isset($info->help)) {
     $info->help = '';
   }
@@ -2514,14 +2514,14 @@ function node_revisions() {
 function node_page_default() {
   $result = pager_query(db_rewrite_sql('SELECT n.nid, n.sticky, n.created FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC'), variable_get('default_nodes_main', 10));
 
-  if (db_num_rows($result)) {
+  $output = '';
+  while ($node = db_fetch_object($result)) {
+    $output .= node_view(node_load($node->nid), 1);
+  }
+
+  if ($output != '') {
     $feed_url = url('rss.xml', array('absolute' => TRUE));
     drupal_add_feed($feed_url, variable_get('site_name', 'Drupal') .' '. t('RSS'));
-
-    $output = '';
-    while ($node = db_fetch_object($result)) {
-      $output .= node_view(node_load($node->nid), 1);
-    }
     $output .= theme('pager', NULL, variable_get('default_nodes_main', 10));
   }
   else {
diff -urpN drupal-6.x-dev-200707302333/modules/ping/ping.module drupal-6.x-dev-rmnumrow-0.1/modules/ping/ping.module
--- drupal-6.x-dev-200707302333/modules/ping/ping.module	2007-07-01 03:46:57.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.1/modules/ping/ping.module	2007-07-31 01:23:53.000000000 +0800
@@ -28,7 +28,7 @@ function ping_cron() {
   global $base_url;
 
   if (variable_get('site_name', 0)) {
-    if (db_num_rows(db_query("SELECT nid FROM {node} WHERE status = 1 AND (created > '". variable_get('cron_last', time()) ."' OR changed > '". variable_get('cron_last', time()) ."')"))) {
+    if (db_result(db_query("SELECT COUNT(nid) FROM {node} WHERE status = 1 AND (created > '". variable_get('cron_last', time()) ."' OR changed > '". variable_get('cron_last', time()) ."')"))) {
       _ping_notify(variable_get('site_name', ''), $base_url);
     }
   }
diff -urpN drupal-6.x-dev-200707302333/modules/statistics/statistics.module drupal-6.x-dev-rmnumrow-0.1/modules/statistics/statistics.module
--- drupal-6.x-dev-200707302333/modules/statistics/statistics.module	2007-07-04 04:10:50.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.1/modules/statistics/statistics.module	2007-07-31 01:32:43.000000000 +0800
@@ -525,18 +525,18 @@ function statistics_block($op = 'list', 
         $content = array();
 
         $daytop = variable_get('statistics_block_top_day_num', 0);
-        if ($daytop && ($result = statistics_title_list('daycount', $daytop)) && db_num_rows($result)) {
-          $content[] = node_title_list($result, t("Today's:"));
+        if ($daytop && ($result = statistics_title_list('daycount', $daytop)) && ($node_title_list = node_title_list($result, t("Today's:")))) {
+          $content[] = $node_title_list;
         }
 
         $alltimetop = variable_get('statistics_block_top_all_num', 0);
-        if ($alltimetop && ($result = statistics_title_list('totalcount', $alltimetop)) && db_num_rows($result)) {
-          $content[] = node_title_list($result, t('All time:'));
+        if ($alltimetop && ($result = statistics_title_list('totalcount', $alltimetop)) && ($node_title_list = node_title_list($result, t('All time:')))) {
+          $content[] = $node_title_list;
         }
 
         $lasttop = variable_get('statistics_block_top_last_num', 0);
-        if ($lasttop && ($result = statistics_title_list('timestamp', $lasttop)) && db_num_rows($result)) {
-          $content[] = node_title_list($result, t('Last viewed:'));
+        if ($lasttop && ($result = statistics_title_list('timestamp', $lasttop)) && ($node_title_list = node_title_list($result, t('Last viewed:')))) {
+          $content[] = $node_title_list;
         }
 
         if (count($content)) {
diff -urpN drupal-6.x-dev-200707302333/modules/system/system.install drupal-6.x-dev-rmnumrow-0.1/modules/system/system.install
--- drupal-6.x-dev-200707302333/modules/system/system.install	2007-07-11 23:15:40.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.1/modules/system/system.install	2007-07-31 01:59:01.000000000 +0800
@@ -1428,8 +1428,9 @@ function system_update_159() {
   $ret = array();
 
   $result = db_query_range("SELECT * FROM {old_revisions} WHERE done = 0 AND type IN ('page', 'story', 'poll', 'book', 'forum', 'blog') ORDER BY nid DESC", 0, 20);
+  $result_rows = db_query_range("SELECT COUNT(*) FROM {old_revisions} WHERE done = 0 AND type IN ('page', 'story', 'poll', 'book', 'forum', 'blog') ORDER BY nid DESC", 0, 20);
 
-  if (db_num_rows($result)) {
+  if ($result_rows) {
     $vid = db_next_id('{node_revisions}_vid');
     while ($node = db_fetch_object($result)) {
       $revisions = unserialize($node->revisions);
@@ -1519,7 +1520,7 @@ function system_update_159() {
     }
   }
 
-  if (db_num_rows($result) < 20) {
+  if ($result_rows < 20) {
     $ret[] = update_sql('ALTER TABLE {old_revisions} DROP done');
   }
   else {
@@ -2179,7 +2180,7 @@ function system_update_179() {
     }
 
     // Done?
-    if (db_num_rows($result) == 0) {
+    if (!$field) {
       unset($_SESSION['system_update_179_uid']);
       unset($_SESSION['system_update_179_fid']);
       unset($_SESSION['system_update_179_max']);
diff -urpN drupal-6.x-dev-200707302333/modules/system/system.module drupal-6.x-dev-rmnumrow-0.1/modules/system/system.module
--- drupal-6.x-dev-200707302333/modules/system/system.module	2007-07-30 01:28:23.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.1/modules/system/system.module	2007-07-31 00:17:04.000000000 +0800
@@ -462,8 +462,8 @@ function system_admin_theme_settings() {
 function system_admin_theme_submit($form, &$form_state) {
   // If we're changing themes, make sure the theme has its blocks initialized.
   if ($form_state['values']['admin_theme'] != variable_get('admin_theme', '0')) {
-    $result = db_query("SELECT status FROM {blocks} WHERE theme = '%s'", $form_state['values']['admin_theme']);
-    if (!db_num_rows($result)) {
+    $result = db_result(db_query("SELECT COUNT(status) FROM {blocks} WHERE theme = '%s'", $form_state['values']['admin_theme']));
+    if (!$result) {
       system_initialize_theme_blocks($form_state['values']['admin_theme']);
     }
   }
@@ -1263,7 +1263,7 @@ function system_default_region($theme) {
  */
 function system_initialize_theme_blocks($theme) {
   // Initialize theme's blocks if none already registered.
-  if (!(db_num_rows(db_query("SELECT module FROM {blocks} WHERE theme = '%s'", $theme)))) {
+  if (!(db_result(db_query("SELECT COUNT(module) FROM {blocks} WHERE theme = '%s'", $theme)))) {
     $default_theme = variable_get('theme_default', 'garland');
     $regions = system_region_list($theme);
     $result = db_query("SELECT * FROM {blocks} WHERE theme = '%s'", $default_theme);
diff -urpN drupal-6.x-dev-200707302333/modules/taxonomy/taxonomy.module drupal-6.x-dev-rmnumrow-0.1/modules/taxonomy/taxonomy.module
--- drupal-6.x-dev-200707302333/modules/taxonomy/taxonomy.module	2007-07-16 20:43:06.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.1/modules/taxonomy/taxonomy.module	2007-07-31 02:46:56.000000000 +0800
@@ -1285,10 +1285,10 @@ function taxonomy_select_nodes($tids = a
 */
 function taxonomy_render_nodes($result) {
   $output = '';
-  if (db_num_rows($result) > 0) {
-    while ($node = db_fetch_object($result)) {
-      $output .= node_view(node_load($node->nid), 1);
-    }
+  while ($node = db_fetch_object($result)) {
+    $output .= node_view(node_load($node->nid), 1);
+  }
+  if ($output != '') {
     $output .= theme('pager', NULL, variable_get('default_nodes_main', 10), 0);
   }
   else {
diff -urpN drupal-6.x-dev-200707302333/modules/translation/translation.module drupal-6.x-dev-rmnumrow-0.1/modules/translation/translation.module
--- drupal-6.x-dev-200707302333/modules/translation/translation.module	2007-07-05 16:48:58.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.1/modules/translation/translation.module	2007-07-31 01:23:26.000000000 +0800
@@ -282,7 +282,7 @@ function translation_nodeapi(&$node, $op
  */
 function translation_remove_from_set($node) {
   if (isset($node->tnid)) {
-    if (db_num_rows(db_query('SELECT tnid FROM {node} WHERE tnid = %d', $node->tnid)) <= 2) {
+    if (db_result(db_query('SELECT COUNT(tnid) FROM {node} WHERE tnid = %d', $node->tnid)) <= 2) {
       // There would only be one node left in the set: remove the set altogether.
       db_query('UPDATE {node} SET tnid = 0, translate = 0 WHERE tnid = %d', $node->tnid);
     }
diff -urpN drupal-6.x-dev-200707302333/modules/user/user.module drupal-6.x-dev-rmnumrow-0.1/modules/user/user.module
--- drupal-6.x-dev-200707302333/modules/user/user.module	2007-07-27 21:08:17.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.1/modules/user/user.module	2007-07-31 02:49:14.000000000 +0800
@@ -150,8 +150,7 @@ function user_load($array = array()) {
   }
   $result = db_query('SELECT * FROM {users} u WHERE '. implode(' AND ', $query), $params);
 
-  if (db_num_rows($result)) {
-    $user = db_fetch_object($result);
+  if ($user = db_fetch_object($result)) {
     $user = drupal_unpack($user);
 
     $user->roles = array();
@@ -473,10 +472,7 @@ function user_fields() {
 
   if (!$fields) {
     $result = db_query('SELECT * FROM {users} WHERE uid = 1');
-    if (db_num_rows($result)) {
-      $fields = array_keys(db_fetch_array($result));
-    }
-    else {
+    if (!($fields = array_keys(db_fetch_array($result)))) {
       // Make sure we return the default fields at least
       $fields = array('uid', 'name', 'pass', 'mail', 'picture', 'mode', 'sort', 'threshold', 'theme', 'signature', 'created', 'access', 'login', 'status', 'timezone', 'language', 'init', 'data');
     }
@@ -689,7 +685,7 @@ function user_block($op = 'list', $delta
           // rather than u.access because it is much faster.
           $anonymous_count = sess_count($interval);
           $authenticated_users = db_query('SELECT DISTINCT u.uid, u.name, s.timestamp FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.timestamp >= %d AND s.uid > 0 ORDER BY s.timestamp DESC', $interval);
-          $authenticated_count = db_num_rows($authenticated_users);
+          $authenticated_count = db_result(db_query('SELECT COUNT(DISTINCT u.uid) FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.timestamp >= %d AND s.uid > 0 ORDER BY s.timestamp DESC', $interval));
 
           // Format the output with proper grammar.
           if ($anonymous_count == 1 && $authenticated_count == 1) {
@@ -1017,15 +1013,11 @@ function user_current_to_arg($arg) {
  */
 function user_get_authmaps($authname = NULL) {
   $result = db_query("SELECT authname, module FROM {authmap} WHERE authname = '%s'", $authname);
-  if (db_num_rows($result) > 0) {
-    while ($authmap = db_fetch_object($result)) {
-      $authmaps[$authmap->module] = $authmap->authname;
-    }
-    return $authmaps;
-  }
-  else {
-    return 0;
+  $authmaps = array();
+  while ($authmap = db_fetch_object($result)) {
+    $authmaps[$authmap->module] = $authmap->authname;
   }
+  return count($authmaps) ? $authmaps : 0;
 }
 
 function user_set_authmaps($account, $authmaps) {
@@ -1577,7 +1569,7 @@ function _user_edit_validate($uid, &$edi
     if ($error = user_validate_name($edit['name'])) {
       form_set_error('name', $error);
     }
-    else if (db_num_rows(db_query("SELECT uid FROM {users} WHERE uid != %d AND LOWER(name) = LOWER('%s')", $uid, $edit['name'])) > 0) {
+    else if (db_result(db_query("SELECT COUNT(uid) FROM {users} WHERE uid != %d AND LOWER(name) = LOWER('%s')", $uid, $edit['name'])) > 0) {
       form_set_error('name', t('The name %name is already taken.', array('%name' => $edit['name'])));
     }
     else if (drupal_is_denied('user', $edit['name'])) {
@@ -1589,7 +1581,7 @@ function _user_edit_validate($uid, &$edi
   if ($error = user_validate_mail($edit['mail'])) {
     form_set_error('mail', $error);
   }
-  else if (db_num_rows(db_query("SELECT uid FROM {users} WHERE uid != %d AND LOWER(mail) = LOWER('%s')", $uid, $edit['mail'])) > 0) {
+  else if (db_result(db_query("SELECT COUNT(uid) FROM {users} WHERE uid != %d AND LOWER(mail) = LOWER('%s')", $uid, $edit['mail'])) > 0) {
     form_set_error('mail', t('The e-mail address %email is already registered. <a href="@password">Have you forgotten your password?</a>', array('%email' => $edit['mail'], '@password' => url('user/password'))));
   }
   else if (drupal_is_denied('mail', $edit['mail'])) {
