summaryrefslogtreecommitdiff
path: root/modules/node
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2007-08-12 15:55:36 +0000
committerDries Buytaert <dries@buytaert.net>2007-08-12 15:55:36 +0000
commitb134b023e11902ceae12f3ab861da1f0a2fdbdbd (patch)
treefc0f0be2b23f047dd692e615e3671318f6d60f4d /modules/node
parent4e6068baf2c4dcb776efbdeb16621ffbdfa42c0f (diff)
downloadbrdo-b134b023e11902ceae12f3ab861da1f0a2fdbdbd.tar.gz
brdo-b134b023e11902ceae12f3ab861da1f0a2fdbdbd.tar.bz2
- Patch #163191 by hswong3i: removed db_num_rows() for compatibility with Oracle and DB2. Also a performance improvement.
Diffstat (limited to 'modules/node')
-rw-r--r--modules/node/content_types.inc2
-rw-r--r--modules/node/node.module25
2 files changed, 16 insertions, 11 deletions
diff --git a/modules/node/content_types.inc b/modules/node/content_types.inc
index d4999d637..3c380add9 100644
--- a/modules/node/content_types.inc
+++ b/modules/node/content_types.inc
@@ -385,7 +385,7 @@ function node_type_delete_confirm(&$form_state, $type) {
$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 --git a/modules/node/node.module b/modules/node/node.module
index d7fe1681a..5c2e75ba5 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -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 {