--- user_import.install	2014-03-09 12:02:43.000000000 +1000
+++ user_import.new.install	2014-07-01 11:42:00.000000000 +1000
@@ -201,41 +201,43 @@ function user_import_update_6001() {
  * Move settings into the 'options' column.
  */
 function user_import_update_6002() {
-  $ret    = array();
   $result = db_query("SELECT * FROM {user_import}");
 
   // Update each import.
-  while ($import = db_fetch_array($result)) {
-    $options                    = unserialize($import['options']);
-    $options['first_line_skip'] = $import['first_line_skip'];
-    $options['contact']         = $import['contact'];
-    $options['username_space']  = $import['username_space'];
-    $options['send_email']      = $import['send_email'];
-    //Avoid using update_sql() as it has issues with serialized data.
-    db_query("UPDATE {user_import} SET options = '%s' WHERE import_id = %d", serialize($options), $import['import_id']);
-  }
+  foreach ($result as $import) {
+    $options = unserialize($import->options);
+    $options['first_line_skip'] = $import->first_line_skip;
+    $options['contact'] = $import->contact;
+    $options['username_space'] = $import->username_space;
+    $options['send_email'] = $import->send_email;
+    
+    db_update('user_import')
+      ->fields(array(
+        'options' => serialize($options),
+      ))
+      ->condition('import_id', $import->import_id)
+      ->execute();
 
-  $ret[] = update_sql('ALTER TABLE {user_import} DROP COLUMN first_line_skip');
-  $ret[] = update_sql('ALTER TABLE {user_import} DROP COLUMN contact');
-  $ret[] = update_sql('ALTER TABLE {user_import} DROP COLUMN username_space');
-  $ret[] = update_sql('ALTER TABLE {user_import} DROP COLUMN send_email');
+  }
+  
+  db_drop_field('user_import', 'first_line_skip');
+  db_drop_field('user_import', 'contact');
+  db_drop_field('user_import', 'username_space');
+  db_drop_field('user_import', 'send_email');
 
-  return $ret;
 }
 
 /**
- * Change the Roles column to LOMGTEXT.
+ * Change the Roles column to LONGTEXT.
  */
 function user_import_update_6003() {
-  $ret = array();
-  db_change_field($ret, 'user_import', 'roles', 'roles', array('type' => 'text', 'size' => 'big', 'not null' => TRUE, 'serialize' => TRUE));
+  $ret = db_change_field('user_import', 'roles', 'roles', array('type' => 'text', 'size' => 'big', 'not null' => TRUE, 'serialize' => TRUE));
 
   return $ret;
 }
 
 /**
- *  Add database field to store the name of a directory associated with an import template.
- *
+ * Add database field to store the name of a directory associated with an import template.
  **/
 function user_import_update_7200(&$sandbox) {
   $field = array(
