Index: includes/install.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/install.inc,v
retrieving revision 1.98
diff -u -p -r1.98 install.inc
--- includes/install.inc	20 Jul 2009 18:51:31 -0000	1.98
+++ includes/install.inc	25 Jul 2009 09:51:09 -0000
@@ -606,7 +606,6 @@ function drupal_uninstall_modules($modul
         }
         $paths[$index] = implode('/', $parts);
       }
-      $placeholders = implode(', ', array_fill(0, count($paths), "'%s'"));
 
       $result = db_select('menu_links')
         ->fields('menu_links')
Index: includes/pager.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/pager.inc,v
retrieving revision 1.67
diff -u -p -r1.67 pager.inc
--- includes/pager.inc	12 May 2009 18:26:41 -0000	1.67
+++ includes/pager.inc	25 Jul 2009 09:51:09 -0000
@@ -217,7 +217,7 @@ function pager_query($query, $limit = 10
   $pager_page_array = explode(',', $page);
 
   // We calculate the total of pages as ceil(items / limit).
-  $pager_total_items[$element] = db_result(db_query($count_query, $args));
+  $pager_total_items[$element] = db_query($count_query, $args)->fetchField();
   $pager_total[$element] = ceil($pager_total_items[$element] / $limit);
   $pager_page_array[$element] = max(0, min((int)$pager_page_array[$element], ((int)$pager_total[$element]) - 1));
   return db_query_range($query, $args, $pager_page_array[$element] * $limit, $limit);
Index: modules/comment/comment.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.admin.inc,v
retrieving revision 1.26
diff -u -p -r1.26 comment.admin.inc
--- modules/comment/comment.admin.inc	1 Jul 2009 20:39:20 -0000	1.26
+++ modules/comment/comment.admin.inc	25 Jul 2009 09:51:10 -0000
@@ -174,7 +174,7 @@ function comment_multiple_delete_confirm
   foreach (array_filter($edit['comments']) as $cid => $value) {
     $comment = comment_load($cid);
     if (is_object($comment) && is_numeric($comment->cid)) {
-      $subject = db_result(db_query('SELECT subject FROM {comment} WHERE cid = %d', $cid));
+      $subject = db_query('SELECT subject FROM {comment} WHERE cid = :cid', array(':cid' => $cid))->fetchField();
       $form['comments'][$cid] = array('#type' => 'hidden', '#value' => $cid, '#prefix' => '<li>', '#suffix' => check_plain($subject) . '</li>');
       $comment_counter++;
     }
Index: modules/comment/comment.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.install,v
retrieving revision 1.40
diff -u -p -r1.40 comment.install
--- modules/comment/comment.install	1 Jul 2009 12:06:21 -0000	1.40
+++ modules/comment/comment.install	25 Jul 2009 09:51:10 -0000
@@ -42,7 +42,18 @@ function comment_uninstall() {
  */
 function comment_enable() {
   // Insert records into the node_comment_statistics for nodes that are missing.
-  db_query("INSERT INTO {node_comment_statistics} (nid, last_comment_timestamp, last_comment_name, last_comment_uid, comment_count) SELECT n.nid, n.changed, NULL, n.uid, 0 FROM {node} n LEFT JOIN {node_comment_statistics} c ON n.nid = c.nid WHERE c.comment_count IS NULL");
+  $query = db_select('node', 'n');
+  $query->leftJoin('node_comment_statistics', 'ncs', 'ncs.nid = n.nid');
+  $query->addField('n', 'changed', 'last_comment_timestamp');
+  $query->addField('n', 'uid', 'last_comment_uid');
+  $query->addField('n', 'nid');
+  $query->addExpression('0', 'comment_count');
+  $query->addExpression('NULL', 'last_comment_name');
+  $query->isNull('ncs.comment_count');
+
+  db_insert('node_comment_statistics')
+    ->from($query)
+    ->execute();
 }
 
 /**
Index: modules/dblog/dblog.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/dblog/dblog.test,v
retrieving revision 1.22
diff -u -p -r1.22 dblog.test
--- modules/dblog/dblog.test	13 Jul 2009 21:51:09 -0000	1.22
+++ modules/dblog/dblog.test	25 Jul 2009 09:51:10 -0000
@@ -210,7 +210,7 @@ class DBLogTestCase extends DrupalWebTes
     $this->drupalPost('user/' . $user->uid . '/cancel', array('user_cancel_method' => 'user_cancel_reassign'), t('Cancel account'));
 
     // Count rows that have uids for the user.
-    $count = db_query('SELECT COUNT(wid) FROM {watchdog} WHERE uid = %d', $user->uid)->fetchField();
+    $count = db_query('SELECT COUNT(wid) FROM {watchdog} WHERE uid = :uid', array(':uid' => $user->uid))->fetchField();
     $this->assertTrue($count == 0, t('DBLog contains @count records for @name', array('@count' => $count, '@name' => $user->name)));
 
     // Count rows in watchdog that previously related to the deleted user.
Index: modules/field/modules/field_sql_storage/field_sql_storage.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/modules/field_sql_storage/field_sql_storage.test,v
retrieving revision 1.5
diff -u -p -r1.5 field_sql_storage.test
--- modules/field/modules/field_sql_storage/field_sql_storage.test	13 Jul 2009 21:51:09 -0000	1.5
+++ modules/field/modules/field_sql_storage/field_sql_storage.test	25 Jul 2009 09:51:10 -0000
@@ -43,8 +43,8 @@ class FieldSqlStorageTestCase extends Dr
     $this->assertEqual($t1+1, $t2, 'Entity type ids are sequential');
     $this->assertIdentical(variable_get('field_sql_storage_t1_etid', NULL), $t1, 'First entity type variable is correct');
     $this->assertIdentical(variable_get('field_sql_storage_t2_etid', NULL), $t2, 'Second entity type variable is correct');
-    $this->assertEqual(db_result(db_query("SELECT etid FROM {field_config_entity_type} WHERE type='t1'")), $t1, 'First entity type in database is correct');
-    $this->assertEqual(db_result(db_query("SELECT etid FROM {field_config_entity_type} WHERE type='t2'")), $t2, 'Second entity type in database is correct');
+    $this->assertEqual(db_query("SELECT etid FROM {field_config_entity_type} WHERE type='t1'")->fetchField(), $t1, 'First entity type in database is correct');
+    $this->assertEqual(db_query("SELECT etid FROM {field_config_entity_type} WHERE type='t2'")->fetchField(), $t2, 'Second entity type in database is correct');
     $this->assertEqual($t1, _field_sql_storage_etid('t1'), '_field_sql_storage_etid returns the same value for the first entity type');
     $this->assertEqual($t2, _field_sql_storage_etid('t2'), '_field_sql_storage_etid returns the same value for the second entity type');
   }
@@ -197,31 +197,31 @@ class FieldSqlStorageTestCase extends Dr
 
     // Insert: Field is missing
     field_attach_insert($entity_type, $entity);
-    $count = db_result(db_query("SELECT COUNT(*) FROM {{$this->table}}"));
+    $count = db_query("SELECT COUNT(*) FROM {{$this->table}}")->fetchField();
     $this->assertEqual($count, 0, 'Missing field results in no inserts');
 
     // Insert: Field is NULL
     $entity->{$this->field_name} = NULL;
     field_attach_insert($entity_type, $entity);
-    $count = db_result(db_query("SELECT COUNT(*) FROM {{$this->table}}"));
+    $count = db_query("SELECT COUNT(*) FROM {{$this->table}}")->fetchField();
     $this->assertEqual($count, 0, 'NULL field results in no inserts');
 
     // Add some real data
     $entity->{$this->field_name} = array(0 => array('value' => 1));
     field_attach_insert($entity_type, $entity);
-    $count = db_result(db_query("SELECT COUNT(*) FROM {{$this->table}}"));
+    $count = db_query("SELECT COUNT(*) FROM {{$this->table}}")->fetchField();
     $this->assertEqual($count, 1, 'Field data saved');
 
     // Update: Field is missing. Data should survive.
     unset($entity->{$this->field_name});
     field_attach_update($entity_type, $entity);
-    $count = db_result(db_query("SELECT COUNT(*) FROM {{$this->table}}"));
+    $count = db_query("SELECT COUNT(*) FROM {{$this->table}}")->fetchField();
     $this->assertEqual($count, 1, 'Missing field leaves data in table');
 
     // Update: Field is NULL. Data should be wiped.
     $entity->{$this->field_name} = NULL;
     field_attach_update($entity_type, $entity);
-    $count = db_result(db_query("SELECT COUNT(*) FROM {{$this->table}}"));
+    $count = db_query("SELECT COUNT(*) FROM {{$this->table}}")->fetchField();
     $this->assertEqual($count, 0, 'NULL field leaves no data in table');
   }
 }
Index: modules/forum/forum.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/forum/forum.install,v
retrieving revision 1.31
diff -u -p -r1.31 forum.install
--- modules/forum/forum.install	22 Jun 2009 13:21:37 -0000	1.31
+++ modules/forum/forum.install	25 Jul 2009 09:51:10 -0000
@@ -17,6 +17,9 @@ function forum_install() {
     ->fields(array('weight' => 1))
     ->condition('name', 'forum')
     ->execute();
+
+  // Set node type options.
+  variable_set('node_options_forum', array('status'));
 }
 
 function forum_enable() {
Index: modules/node/node.api.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.api.php,v
retrieving revision 1.27
diff -u -p -r1.27 node.api.php
--- modules/node/node.api.php	11 Jul 2009 13:56:21 -0000	1.27
+++ modules/node/node.api.php	25 Jul 2009 09:51:11 -0000
@@ -764,8 +764,12 @@ function hook_form($node, $form_state) {
  * For a detailed usage example, see node_example.module.
  */
 function hook_insert($node) {
-  db_query("INSERT INTO {mytable} (nid, extra)
-    VALUES (%d, '%s')", $node->nid, $node->extra);
+  db_insert('mytable')
+    ->fields(array(
+      'nid' => $node->nid,
+      'extra' => $node->extra,
+    ))
+    ->execute();
 }
 
 /**
@@ -806,8 +810,10 @@ function hook_load($nodes) {
  * For a detailed usage example, see node_example.module.
  */
 function hook_update($node) {
-  db_query("UPDATE {mytable} SET extra = '%s' WHERE nid = %d",
-    $node->extra, $node->nid);
+  db_update('mytable')
+    ->fields(array('extra' => $node->extra))
+    ->condition('nid', $node->nid)
+    ->execute();
 }
 
 /**
Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.1085
diff -u -p -r1.1085 node.module
--- modules/node/node.module	20 Jul 2009 22:18:53 -0000	1.1085
+++ modules/node/node.module	25 Jul 2009 09:51:13 -0000
@@ -2708,7 +2708,7 @@ function _node_access_rebuild_batch_oper
 
   // Process the next 20 nodes.
   $limit = 20;
-  $nids = db_query_range("SELECT nid FROM {node} WHERE nid > %d ORDER BY nid ASC", $context['sandbox']['current_node'], 0, $limit)->fetchCol();
+  $nids = db_query_range("SELECT nid FROM {node} WHERE nid > :nid ORDER BY nid ASC", array(':nid' => $context['sandbox']['current_node']), 0, $limit)->fetchCol();
   $nodes = node_load_multiple($nids, array(), TRUE);
   foreach ($nodes as $node) {
     // To preserve database integrity, only acquire grants if the node
@@ -3157,7 +3157,7 @@ function node_requirements($phase) {
   // Only show rebuild button if there are either 0, or 2 or more, rows
   // in the {node_access} table, or if there are modules that
   // implement hook_node_grants().
-  $grant_count = db_result(db_query('SELECT COUNT(*) FROM {node_access}'));
+  $grant_count = db_query('SELECT COUNT(*) FROM {node_access}')->fetchField();
   if ($grant_count != 1 || count(module_implements('node_grants')) > 0) {
     $value = format_plural($grant_count, 'One permission in use', '@count permissions in use', array('@count' => $grant_count));
   } else {
Index: modules/node/node.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.test,v
retrieving revision 1.37
diff -u -p -r1.37 node.test
--- modules/node/node.test	20 Jul 2009 18:51:33 -0000	1.37
+++ modules/node/node.test	25 Jul 2009 09:51:13 -0000
@@ -681,7 +681,7 @@ class NodeAccessRecordsUnitTest extends 
     $this->assertTrue(node_load($node1->nid), t('Article node created.'));
 
     // Check to see if grants added by node_test_node_access_records made it in.
-    $records = db_query('SELECT realm, gid FROM {node_access} WHERE nid = %d', $node1->nid)->fetchAll();
+    $records = db_query('SELECT realm, gid FROM {node_access} WHERE nid = :nid', array(':nid' => $node1->nid))->fetchAll();
     $this->assertEqual(count($records), 1, t('Returned the correct number of rows.'));
     $this->assertEqual($records[0]->realm, 'test_article_realm', t('Grant with article_realm acquired for node without alteration.'));
     $this->assertEqual($records[0]->gid, 1, t('Grant with gid = 1 acquired for node without alteration.'));
@@ -691,7 +691,7 @@ class NodeAccessRecordsUnitTest extends 
     $this->assertTrue(node_load($node1->nid), t('Unpromoted page node created.'));
 
     // Check to see if grants added by node_test_node_access_records made it in.
-    $records = db_query('SELECT realm, gid FROM {node_access} WHERE nid = %d', $node2->nid)->fetchAll();
+    $records = db_query('SELECT realm, gid FROM {node_access} WHERE nid = :nid', array(':nid' => $node2->nid))->fetchAll();
     $this->assertEqual(count($records), 1, t('Returned the correct number of rows.'));
     $this->assertEqual($records[0]->realm, 'test_page_realm', t('Grant with page_realm acquired for node without alteration.'));
     $this->assertEqual($records[0]->gid, 1, t('Grant with gid = 1 acquired for node without alteration.'));
@@ -712,7 +712,7 @@ class NodeAccessRecordsUnitTest extends 
 
     // Check to see if grant added by node_test_node_access_records was altered
     // by node_test_node_access_records_alter.
-    $records = db_query('SELECT realm, gid FROM {node_access} WHERE nid = %d', $node4->nid)->fetchAll();
+    $records = db_query('SELECT realm, gid FROM {node_access} WHERE nid =:nid', array(':nid' => $node3->nid))->fetchAll();
     $this->assertEqual(count($records), 1, t('Returned the correct number of rows.'));
     $this->assertEqual($records[0]->realm, 'test_alter_realm', t('Altered grant with alter_realm acquired for node.'));
     $this->assertEqual($records[0]->gid, 2, t('Altered grant with gid = 2 acquired for node.'));
@@ -759,7 +759,7 @@ class NodeSaveTestCase extends DrupalWeb
    */
   function testImport() {
     // Node ID must be a number that is not in the database.
-    $max_nid = db_result(db_query('SELECT MAX(nid) FROM {node}'));
+    $max_nid = db_query('SELECT MAX(nid) FROM {node}')->fetchField();
     $test_nid = $max_nid + mt_rand(1000, 1000000);
     $title = $this->randomName(8);
     $node = array(
Index: modules/profile/profile.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/profile/profile.module,v
retrieving revision 1.261
diff -u -p -r1.261 profile.module
--- modules/profile/profile.module	3 Jun 2009 07:28:28 -0000	1.261
+++ modules/profile/profile.module	25 Jul 2009 09:51:14 -0000
@@ -341,7 +341,7 @@ function profile_view_profile(&$user) {
 
   // Show private fields to administrators and people viewing their own account.
   if (user_access('administer users') || $GLOBALS['user']->uid == $user->uid) {
-    $result = db_query('SELECT * FROM {profile_field} WHERE visibility <> %d ORDER BY category, weight', PROFILE_HIDDEN);
+    $result = db_query('SELECT * FROM {profile_field} WHERE visibility <> :hidden ORDER BY category, weight', array(':hidden' => PROFILE_HIDDEN));
   }
   else {
     $result = db_query('SELECT * FROM {profile_field} WHERE visibility <> :private AND visibility <> :hidden ORDER BY category, weight', array(':private' => PROFILE_PRIVATE, ':hidden' => PROFILE_HIDDEN));
Index: modules/profile/profile.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/profile/profile.test,v
retrieving revision 1.16
diff -u -p -r1.16 profile.test
--- modules/profile/profile.test	20 Jul 2009 18:51:34 -0000	1.16
+++ modules/profile/profile.test	25 Jul 2009 09:51:14 -0000
@@ -37,7 +37,7 @@ class ProfileTestCase extends DrupalWebT
     $edit['explanation'] = $this->randomName(50);
 
     $this->drupalPost('admin/user/profile/add/' . $type, $edit, t('Save field'));
-    $fid = db_result(db_query("SELECT fid FROM {profile_field} WHERE title = '%s'", $title));
+    $fid = db_query("SELECT fid FROM {profile_field} WHERE title = :title", array(':title' => $title))->fetchField();
     $this->assertTrue($fid, t('New Profile field has been entered in the database'));
 
     // Check that the new field is appearing on the user edit form.
Index: modules/simpletest/simpletest.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/simpletest.module,v
retrieving revision 1.61
diff -u -p -r1.61 simpletest.module
--- modules/simpletest/simpletest.module	20 Jul 2009 18:51:34 -0000	1.61
+++ modules/simpletest/simpletest.module	25 Jul 2009 09:51:14 -0000
@@ -221,10 +221,10 @@ function _simpletest_batch_finished($suc
  *   The test ID to read log file for.
  */
 function simpletest_log_read($test_id) {
-  $last_prefix = db_result(db_query('SELECT last_prefix FROM {simpletest_test_id} WHERE test_id = :test_id', array(':test_id' => $test_id)));
+  $last_prefix = db_query('SELECT last_prefix FROM {simpletest_test_id} WHERE test_id = :test_id', array(':test_id' => $test_id))->fetchField();
   $last_prefix = substr($last_prefix, 10);
 
-  $test_class = db_result(db_query('SELECT test_class FROM {simpletest} WHERE test_id = :test_id ORDER BY message_id', array(':test_id' => $test_id)));
+  $test_class = db_query('SELECT test_class FROM {simpletest} WHERE test_id = :test_id ORDER BY message_id', array(':test_id' => $test_id))->fetchField();
   $log = file_directory_path() . "/simpletest/$last_prefix/error.log";
   if (file_exists($log)) {
     foreach (file($log) as $line) {
Index: modules/statistics/statistics.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/statistics/statistics.module,v
retrieving revision 1.308
diff -u -p -r1.308 statistics.module
--- modules/statistics/statistics.module	20 Jul 2009 18:51:34 -0000	1.308
+++ modules/statistics/statistics.module	25 Jul 2009 09:51:15 -0000
@@ -394,5 +394,5 @@ function statistics_ranking() {
  * Implement hook_update_index().
  */
 function statistics_update_index() {
-  variable_set('node_cron_views_scale', 1.0 / max(1, db_result(db_query('SELECT MAX(totalcount) FROM {node_counter}'))));
+  variable_set('node_cron_views_scale', 1.0 / max(1, db_query('SELECT MAX(totalcount) FROM {node_counter}'))->fetchField());
 }
Index: modules/system/system.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.install,v
retrieving revision 1.356
diff -u -p -r1.356 system.install
--- modules/system/system.install	21 Jul 2009 07:27:00 -0000	1.356
+++ modules/system/system.install	25 Jul 2009 09:51:16 -0000
@@ -373,13 +373,11 @@ function system_install() {
 
   // Built-in roles.
   $rid_anonymous = db_insert('role')
-    ->fields(array('name'))
-    ->values(array('name' => 'anonymous user'))
+    ->fields(array('name' => 'anonymous user'))
     ->execute();
 
   $rid_authenticated = db_insert('role')
-    ->fields(array('name'))
-    ->values(array('name' => 'authenticated user'))
+    ->fields(array('name' => 'authenticated user'))
     ->execute();
 
   // Sanity check to ensure the anonymous and authenticated role IDs are the
@@ -1538,7 +1536,7 @@ function system_update_7003() {
     ':status' => 0,
     ':type' => $type,
   ));
-  while ($blocked = db_fetch_object($result)) {
+  foreach ($result as $blocked) {
     if (filter_var($blocked->mask, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE) !== FALSE) {
       $ret[] = update_sql("INSERT INTO {blocked_ips} (ip) VALUES ('$blocked->mask')");
     }
Index: modules/trigger/trigger.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/trigger/trigger.test,v
retrieving revision 1.14
diff -u -p -r1.14 trigger.test
--- modules/trigger/trigger.test	20 Jul 2009 18:51:35 -0000	1.14
+++ modules/trigger/trigger.test	25 Jul 2009 09:51:16 -0000
@@ -60,7 +60,7 @@ class TriggerContentTestCase extends Dru
       // Test 3: The action should be able to be unassigned from a trigger.
       $this->drupalPost('admin/structure/trigger/unassign/node/presave/' . $hash, array(), t('Unassign'));
       $this->assertRaw(t('Action %action has been unassigned.', array('%action' => ucfirst($info['name']))), t('Check to make sure the @action action can be unassigned from the trigger.', array('@action' => $info['name'])));
-      $assigned = db_result(db_query("SELECT COUNT(*) FROM {trigger_assignments} WHERE aid IN ('" . implode("','", $content_actions) . "')"));
+      $assigned = db_query("SELECT COUNT(*) FROM {trigger_assignments} WHERE aid IN (:keys)", array(':keys' => $content_actions))->fetchField();
       $this->assertFalse($assigned, t('Check to make sure unassign worked properly at the database level.'));
     }
   }
Index: modules/upload/upload.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/upload/upload.test,v
retrieving revision 1.21
diff -u -p -r1.21 upload.test
--- modules/upload/upload.test	13 Jul 2009 21:51:42 -0000	1.21
+++ modules/upload/upload.test	25 Jul 2009 09:51:16 -0000
@@ -68,7 +68,7 @@ class UploadTestCase extends DrupalWebTe
     $this->assertTrue(strpos($teaser, format_plural(2, '1 attachment', '@count attachments')), 'Attachments link found on node teaser.');
 
     // Fetch db record and use fid to rename and delete file.
-    $upload = db_fetch_object(db_query('SELECT fid, description FROM {upload} WHERE nid = %d', array($node->nid)));
+    $upload = db_query('SELECT fid, description FROM {upload} WHERE nid = :nid', array(':nid' => $node->nid))->fetchObject();
     if ($upload) {
       // Rename file.
       $edit = array();
Index: modules/user/user.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.test,v
retrieving revision 1.47
diff -u -p -r1.47 user.test
--- modules/user/user.test	20 Jul 2009 18:51:35 -0000	1.47
+++ modules/user/user.test	25 Jul 2009 09:51:17 -0000
@@ -1044,7 +1044,7 @@ class UserSaveTestCase extends DrupalWeb
    */
   function testUserImport() {
     // User ID must be a number that is not in the database.
-    $max_uid = db_result(db_query('SELECT MAX(uid) FROM {users}'));
+    $max_uid = db_query('SELECT MAX(uid) FROM {users}')->fetchField();
     $test_uid = $max_uid + mt_rand(1000, 1000000);
     $test_name = $this->randomName();
 
