? blog_dbtng_conversion.patch
? sites/default/files
? sites/default/settings.php
Index: modules/blog/blog.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/blog/blog.module,v
retrieving revision 1.316
diff -u -p -r1.316 blog.module
--- modules/blog/blog.module	31 Dec 2008 12:02:21 -0000	1.316
+++ modules/blog/blog.module	8 Mar 2009 03:36:46 -0000
@@ -161,9 +161,18 @@ function blog_page_user_access($account)
  * Helper function to determine if a user has blog posts already.
  */
 function _blog_post_exists($account) {
-  return (bool)db_result(db_query_range(db_rewrite_sql("SELECT 1 FROM {node} n WHERE n.type = 'blog' AND n.uid = %d AND n.status = 1"), $account->uid, 0, 1));
+  return (bool)db_select('node', 'n')
+    ->condition('type', 'blog')
+    ->condition('uid', $account->uid)
+    ->condition('status', 1)
+    ->range(0, 1)
+    ->addTag('node_access')
+    ->addExpression(1)
+    ->execute()
+    ->fetchField();
 }
 
+
 /**
  * Implementation of hook_block_list().
  */
@@ -181,7 +190,14 @@ function blog_block_view($delta = '') {
   global $user;
 
   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);
+    $result = db_select('node', 'n')
+      ->fields('n', array('nid', 'title', 'created'))
+      ->condition('type', 'blog')
+      ->condition('status', 1)
+      ->orderBy('created', 'DESC')
+      ->range(0, 10)
+      ->execute();
+
     if ($node_title_list = node_title_list($result)) {
       $block['content'] = $node_title_list;
       $block['content'] .= theme('more_link', url('blog'), t('Read the latest blog entries.'));
Index: modules/blog/blog.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/blog/blog.pages.inc,v
retrieving revision 1.15
diff -u -p -r1.15 blog.pages.inc
--- modules/blog/blog.pages.inc	27 Jan 2009 00:22:25 -0000	1.15
+++ modules/blog/blog.pages.inc	8 Mar 2009 03:36:46 -0000
@@ -29,7 +29,18 @@ function blog_page_user($account) {
     '#weight' => -1,
   );
 
-  $nids = pager_query(db_rewrite_sql("SELECT n.nid, n.sticky, n.created FROM {node} n WHERE n.type = 'blog' AND n.uid = %d AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC"), variable_get('default_nodes_main', 10), 0, NULL, $account->uid)->fetchCol();
+  $nids = db_select('node', 'n')
+    ->fields('n', array('nid', 'sticky', 'created'))
+    ->condition('type', 'blog')
+    ->condition('uid', $account->uid)
+    ->condition('status', 1)
+    ->orderBy('sticky', 'DESC')
+    ->orderBy('created', 'DESC')
+    ->extend('PagerDefault')
+    ->limit(variable_get('default_nodes_main', 10))
+    ->execute()
+    ->fetchCol();
+
   if (!empty($nids)) {
     $nodes = node_load_multiple($nids);
     $build += node_build_multiple($nodes);
@@ -67,7 +78,16 @@ function blog_page_last() {
     );
   }
 
-  $nids = pager_query(db_rewrite_sql("SELECT n.nid, n.sticky, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC"), variable_get('default_nodes_main', 10))->fetchCol();
+  $nids = db_select('node', 'n')
+    ->fields('n', array('nid', 'sticky', 'created'))
+    ->condition('type', 'blog')
+    ->condition('status', 1)
+    ->orderBy('sticky', 'DESC')
+    ->orderBy('created', 'DESC')
+    ->extend('PagerDefault')
+    ->limit(variable_get('default_nodes_main', 10))
+    ->execute()
+    ->fetchCol();
 
   if (!empty($nids)) {
     $nodes = node_load_multiple($nids);
@@ -89,28 +109,38 @@ function blog_page_last() {
  * Menu callback; displays an RSS feed containing recent blog entries of a given user.
  */
 function blog_feed_user($account) {
-  $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n  WHERE n.type = 'blog' AND n.uid = %d AND n.status = 1 ORDER BY n.created DESC"), $account->uid, 0, variable_get('feed_default_items', 10));
+
+  $nids = db_select('node', 'n')
+    ->fields('n', array('nid', 'created'))
+    ->condition('type', 'blog')
+    ->condition('uid', $account->uid)
+    ->condition('status', 1)
+    ->orderBy('created', 'DESC')
+    ->range(0, variable_get('feed_default_items', 10))
+    ->execute()
+    ->fetchCol();
+
   $channel['title'] = $account->name . "'s blog";
   $channel['link'] = url('blog/' . $account->uid, array('absolute' => TRUE));
 
-  $items = array();
-  while ($row = db_fetch_object($result)) {
-    $items[] = $row->nid;
-  }
-  node_feed($items, $channel);
+  node_feed($nids, $channel);
 }
 
 /**
  * Menu callback; displays an RSS feed containing recent blog entries of all users.
  */
 function blog_feed_last() {
-  $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC"), 0, variable_get('feed_default_items', 10));
+  $nids = db_select('node', 'n')
+    ->fields('n', array('nid', 'created'))
+    ->condition('type', 'blog')
+    ->condition('status', 1)
+    ->orderBy('created', 'DESC')
+    ->range(0, variable_get('feed_default_items', 10))
+    ->execute()
+    ->fetchCol();
+
   $channel['title'] = variable_get('site_name', 'Drupal') . ' blogs';
   $channel['link'] = url('blog', array('absolute' => TRUE));
 
-  $items = array();
-  while ($row = db_fetch_object($result)) {
-    $items[] = $row->nid;
-  }
-  node_feed($items, $channel);
+  node_feed($nids, $channel);
 }
Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.1027
diff -u -p -r1.1027 node.module
--- modules/node/node.module	26 Feb 2009 07:30:27 -0000	1.1027
+++ modules/node/node.module	8 Mar 2009 03:36:48 -0000
@@ -212,7 +212,7 @@ function node_field_build_modes($obj_typ
 function node_title_list($result, $title = NULL) {
   $items = array();
   $num_rows = FALSE;
-  while ($node = db_fetch_object($result)) {
+  foreach ($result as $node) {
     $items[] = l($node->title, 'node/' . $node->nid, !empty($node->comment_count) ? array('attributes' => array('title' => format_plural($node->comment_count, '1 comment', '@count comments'))) : array());
     $num_rows = TRUE;
   }
