diff --git scripts/dump-database-d6.sh scripts/dump-database-d6.sh
index 0feb634..0cc656f 100644
--- scripts/dump-database-d6.sh
+++ scripts/dump-database-d6.sh
@@ -3,13 +3,13 @@
 // $Id: dump-database-d6.sh,v 1.3 2010/07/30 01:28:00 dries Exp $
 
 /**
- * Dump a Drupal 6 database into a Drupal 7 PHP script to test the upgrade
+ * Dump a Drupal 6 or 7 database into a Drupal 7 PHP script to test the upgrade
  * process.
  *
- * Run this script at the root of an existing Drupal 6 installation.
+ * Run this script at the root of an existing Drupal 6 or 7 installation.
  *
  * The output of this script is a PHP script that can be ran inside Drupal 7
- * and recreates the Drupal 6 database as dumped. Transient data from cache
+ * and recreates the Drupal database as dumped. Transient data from cache
  * session and watchdog tables are not recorded.
  */
 
@@ -24,6 +24,9 @@ $_SERVER['QUERY_STRING']    = '';
 $_SERVER['PHP_SELF']        = $_SERVER['REQUEST_URI'] = '/';
 $_SERVER['HTTP_USER_AGENT'] = 'console';
 
+// Root directory of Drupal installation.
+define('DRUPAL_ROOT', getcwd());
+
 // Bootstrap Drupal.
 include_once './includes/bootstrap.inc';
 drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
@@ -31,6 +34,9 @@ drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
 // Include the utility drupal_var_export() function.
 include_once dirname(__FILE__) . '/../includes/utility.inc';
 
+$version = VERSION;
+$drupal_core = DRUPAL_CORE_COMPATIBILITY;
+
 // Output the PHP header.
 $output = <<<ENDOFHEADER
 <?php
@@ -38,11 +44,11 @@ $output = <<<ENDOFHEADER
 
 /**
  * @file
- * Filled installation of Drupal 6.17, for test purposes.
+ * Filled installation of Drupal {$version}, for test purposes.
  *
  * This file was generated by the dump-database-d6.sh tool, from an
- * installation of Drupal 6, filled with data using the generate-d6-content.sh
- * tool. It has the following modules installed:
+ * installation of Drupal {$drupal_core}. Content may have been generated using
+ * the generate-d6-content.sh tool. It has the following modules installed:
 
 ENDOFHEADER;
 
@@ -75,14 +81,26 @@ foreach ($schema as $table => $data) {
   // Prepare the export of values.
   $result = db_query('SELECT * FROM {'. $table .'}');
   $insert = '';
-  while ($record = db_fetch_array($result)) {
-    // users.uid is a serial and inserting 0 into a serial can break MySQL.
-    // So record uid + 1 instead of uid for every uid and once all records
-    // are in place, fix them up.
-    if ($table == 'users') {
-      $record['uid']++;
+  if (!function_exists('db_fetch_array')) {
+    $result->setFetchMode(PDO::FETCH_ASSOC);
+    foreach ($result as $record) {
+      // {users}.uid is a serial and inserting 0 into a serial can break MySQL.
+      // So record uid + 1 instead of uid for every uid and once all records
+      // are in place, fix them up.
+      if ($table == 'users') {
+        $record['uid']++;
+      }
+      $insert .= '->values('. drupal_var_export($record) .")\n";
+    }
+  }
+  else {
+    while ($record = db_fetch_array($result)) {
+      // Record uid + 1 instead of uid for every {users}.uid.
+      if ($table == 'users') {
+        $record['uid']++;
+      }
+      $insert .= '->values('. drupal_var_export($record) .")\n";
     }
-    $insert .= '->values('. drupal_var_export($record) .")\n";
   }
 
   // Dump the values if there are some.
