diff -urpN drupal-6.x-dev-200708102212/includes/common.inc drupal-6.x-dev-rmnumrow-0.8.1/includes/common.inc
--- drupal-6.x-dev-200708102212/includes/common.inc	2007-08-03 04:08:52.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.8.1/includes/common.inc	2007-08-10 22:25:32.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(*) 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-200708102212/includes/database.mysqli.inc drupal-6.x-dev-rmnumrow-0.8.1/includes/database.mysqli.inc
--- drupal-6.x-dev-200708102212/includes/database.mysqli.inc	2007-07-23 16:05:14.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.8.1/includes/database.mysqli.inc	2007-08-10 22:30:59.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() does
+ * 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-200708102212/includes/database.mysql.inc drupal-6.x-dev-rmnumrow-0.8.1/includes/database.mysql.inc
--- drupal-6.x-dev-200708102212/includes/database.mysql.inc	2007-07-23 16:05:14.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.8.1/includes/database.mysql.inc	2007-08-10 22:28:24.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() does
+ * 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-200708102212/includes/database.pgsql.inc drupal-6.x-dev-rmnumrow-0.8.1/includes/database.pgsql.inc
--- drupal-6.x-dev-200708102212/includes/database.pgsql.inc	2007-07-23 16:05:14.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.8.1/includes/database.pgsql.inc	2007-08-10 22:31:10.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() does
+ * 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(*) FROM pg_class WHERE relname = '{". db_escape_table($table) ."}'"));
 }
 
 /**
diff -urpN drupal-6.x-dev-200708102212/includes/locale.inc drupal-6.x-dev-rmnumrow-0.8.1/includes/locale.inc
--- drupal-6.x-dev-200708102212/includes/locale.inc	2007-08-09 18:12:14.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.8.1/includes/locale.inc	2007-08-10 22:25:32.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(*) 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-200708102212/includes/menu.inc drupal-6.x-dev-rmnumrow-0.8.1/includes/menu.inc
--- drupal-6.x-dev-200708102212/includes/menu.inc	2007-08-07 16:41:24.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.8.1/includes/menu.inc	2007-08-10 22:25:32.000000000 +0800
@@ -720,7 +720,7 @@ function menu_tree_page_data($menu_name 
                 $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-200708102212/includes/session.inc drupal-6.x-dev-rmnumrow-0.8.1/includes/session.inc
--- drupal-6.x-dev-200708102212/includes/session.inc	2007-07-23 15:29:29.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.8.1/includes/session.inc	2007-08-10 22:25:32.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(*) 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-200708102212/modules/aggregator/aggregator.module drupal-6.x-dev-rmnumrow-0.8.1/modules/aggregator/aggregator.module
--- drupal-6.x-dev-200708102212/modules/aggregator/aggregator.module	2007-07-16 20:43:04.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.8.1/modules/aggregator/aggregator.module	2007-08-10 22:25:32.000000000 +0800
@@ -963,11 +963,11 @@ 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;
-    }
+  $items = array();
+  while ($item = db_fetch_object($result)) {
+    $items[] = $item->iid;
+  }
+  if ($item) {
     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-200708102212/modules/block/block.admin.inc drupal-6.x-dev-rmnumrow-0.8.1/modules/block/block.admin.inc
--- drupal-6.x-dev-200708102212/modules/block/block.admin.inc	2007-07-25 02:17:30.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.8.1/modules/block/block.admin.inc	2007-08-10 22:25:32.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(*) 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(*) 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-200708102212/modules/blog/blog.module drupal-6.x-dev-rmnumrow-0.8.1/modules/blog/blog.module
--- drupal-6.x-dev-200708102212/modules/blog/blog.module	2007-07-22 14:48:25.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.8.1/modules/blog/blog.module	2007-08-10 22:25:32.000000000 +0800
@@ -192,8 +192,8 @@ 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);
+      if ($node_title_list = node_title_list($result)) {
+        $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-200708102212/modules/comment/comment.module drupal-6.x-dev-rmnumrow-0.8.1/modules/comment/comment.module
--- drupal-6.x-dev-200708102212/modules/comment/comment.module	2007-07-31 05:27:34.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.8.1/modules/comment/comment.module	2007-08-11 02:34:50.000000000 +0800
@@ -1016,12 +1016,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);
@@ -1031,37 +1029,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 ($comment && (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 ($comment && (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-200708102212/modules/drupal/drupal.module drupal-6.x-dev-rmnumrow-0.8.1/modules/drupal/drupal.module
--- drupal-6.x-dev-200708102212/modules/drupal/drupal.module	2007-07-01 03:46:55.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.8.1/modules/drupal/drupal.module	2007-08-10 22:25:32.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-200708102212/modules/forum/forum.module drupal-6.x-dev-rmnumrow-0.8.1/modules/forum/forum.module
--- drupal-6.x-dev-200708102212/modules/forum/forum.module	2007-08-03 14:07:52.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.8.1/modules/forum/forum.module	2007-08-10 22:25:32.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-200708102212/modules/node/content_types.inc drupal-6.x-dev-rmnumrow-0.8.1/modules/node/content_types.inc
--- drupal-6.x-dev-200708102212/modules/node/content_types.inc	2007-07-02 01:41:15.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.8.1/modules/node/content_types.inc	2007-08-10 22:25:32.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-200708102212/modules/node/node.module drupal-6.x-dev-rmnumrow-0.8.1/modules/node/node.module
--- drupal-6.x-dev-200708102212/modules/node/node.module	2007-08-10 19:14:22.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.8.1/modules/node/node.module	2007-08-11 02:35:24.000000000 +0800
@@ -106,19 +106,24 @@ function node_cron() {
  * Gather a listing of links to nodes.
  *
  * @param $result
- *   A DB result object from a query to fetch node objects. If your query joins the <code>node_comment_statistics</code> table so that the <code>comment_count</code> field is available, a title attribute will be added to show the number of comments.
+ *   A DB result object from a query to fetch node objects. If your query
+ *   joins the <code>node_comment_statistics</code> table so that the
+ *   <code>comment_count</code> field is available, a title attribute will
+ *   be added to show the number of comments.
  * @param $title
  *   A heading for the resulting list.
  *
  * @return
- *   An HTML list suitable as content for a block.
+ *   An HTML list suitable as content for a block, or FALSE if no result can
+ *   fetch from DB result object.
  */
 function node_title_list($result, $title = NULL) {
+  $items = array();
   while ($node = db_fetch_object($result)) {
     $items[] = l($node->title, 'node/'. $node->nid, !empty($node->comment_count) ? array('title' => format_plural($node->comment_count, '1 comment', '@count comments')) : array());
   }
 
-  return theme('node_list', $items, $title);
+  return $node ? theme('node_list', $items, $title) : FALSE;
 }
 
 /**
@@ -377,7 +382,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 = '';
   }
@@ -2551,14 +2556,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 ($node) {
     $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-200708102212/modules/ping/ping.module drupal-6.x-dev-rmnumrow-0.8.1/modules/ping/ping.module
--- drupal-6.x-dev-200708102212/modules/ping/ping.module	2007-07-01 03:46:57.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.8.1/modules/ping/ping.module	2007-08-10 22:25:32.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(*) 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-200708102212/modules/statistics/statistics.module drupal-6.x-dev-rmnumrow-0.8.1/modules/statistics/statistics.module
--- drupal-6.x-dev-200708102212/modules/statistics/statistics.module	2007-07-04 04:10:50.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.8.1/modules/statistics/statistics.module	2007-08-10 22:25:32.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-200708102212/modules/system/system.install drupal-6.x-dev-rmnumrow-0.8.1/modules/system/system.install
--- drupal-6.x-dev-200708102212/modules/system/system.install	2007-08-07 16:32:43.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.8.1/modules/system/system.install	2007-08-10 22:25:32.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_result(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-200708102212/modules/system/system.module drupal-6.x-dev-rmnumrow-0.8.1/modules/system/system.module
--- drupal-6.x-dev-200708102212/modules/system/system.module	2007-08-10 18:51:17.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.8.1/modules/system/system.module	2007-08-10 22:25:32.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(*) FROM {blocks} WHERE theme = '%s'", $form_state['values']['admin_theme']));
+    if (!$result) {
       system_initialize_theme_blocks($form_state['values']['admin_theme']);
     }
   }
@@ -1265,7 +1265,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(*) 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-200708102212/modules/taxonomy/taxonomy.module drupal-6.x-dev-rmnumrow-0.8.1/modules/taxonomy/taxonomy.module
--- drupal-6.x-dev-200708102212/modules/taxonomy/taxonomy.module	2007-08-08 15:18:19.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.8.1/modules/taxonomy/taxonomy.module	2007-08-11 02:35:58.000000000 +0800
@@ -983,10 +983,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 ($node) {
     $output .= theme('pager', NULL, variable_get('default_nodes_main', 10), 0);
   }
   else {
diff -urpN drupal-6.x-dev-200708102212/modules/translation/translation.module drupal-6.x-dev-rmnumrow-0.8.1/modules/translation/translation.module
--- drupal-6.x-dev-200708102212/modules/translation/translation.module	2007-07-05 16:48:58.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.8.1/modules/translation/translation.module	2007-08-10 22:25:32.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(*) 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-200708102212/modules/user/user.module drupal-6.x-dev-rmnumrow-0.8.1/modules/user/user.module
--- drupal-6.x-dev-200708102212/modules/user/user.module	2007-08-09 18:49:26.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.8.1/modules/user/user.module	2007-08-10 22:25:32.000000000 +0800
@@ -151,8 +151,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();
@@ -474,8 +473,8 @@ 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));
+    if ($field = db_fetch_array($result)) {
+      $fields = array_keys($field);
     }
     else {
       // Make sure we return the default fields at least
@@ -700,7 +699,16 @@ 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 = 0;
+          $max_users = variable_get('user_block_max_list_count', 10);
+          $items = array();
+          while ($account = db_fetch_object($authenticated_users)) {
+            if ($max_users > 0) {
+              $items[] = $account;
+              $max_users--;
+            }
+            $authenticated_count++;
+          }
 
           // Format the output with proper grammar.
           if ($anonymous_count == 1 && $authenticated_count == 1) {
@@ -713,12 +721,6 @@ function user_block($op = 'list', $delta
           // Display a list of currently online users.
           $max_users = variable_get('user_block_max_list_count', 10);
           if ($authenticated_count && $max_users) {
-            $items = array();
-
-            while ($max_users-- && $account = db_fetch_object($authenticated_users)) {
-              $items[] = $account;
-            }
-
             $output .= theme('user_list', $items, t('Online users'));
           }
 
@@ -1093,15 +1095,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) {
@@ -1653,7 +1651,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(*) 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'])) {
@@ -1665,7 +1663,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(*) 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'])) {
