diff --git a/includes/destinations.db.mysql.inc b/includes/destinations.db.mysql.inc
index 019da7b..25d7ff9 100644
--- a/includes/destinations.db.mysql.inc
+++ b/includes/destinations.db.mysql.inc
@@ -312,17 +312,10 @@ class backup_migrate_destination_db_mysql extends backup_migrate_destination_db
     $data = $this->query("SELECT * FROM `". $table['name'] ."`", array(), array('fetch' => PDO::FETCH_ASSOC));
     $rows = $bytes = 0;
 
-    // Escape backslashes, PHP code, special chars
-    $search = array('\\', "'", "\x00", "\x0a", "\x0d", "\x1a");
-    $replace = array('\\\\', "''", '\0', '\n', '\r', '\Z');
-  
     $line = array();
     foreach ($data as $row) {
       // DB Escape the values.
-      $items = array();
-      foreach ($row as $key => $value) {
-        $items[] = is_null($value) ? "null" : "'". str_replace($search, $replace, $value) ."'";
-      }
+      $items = _db_prepare_row($row);
   
       // If there is a row to be added.
       if ($items) {
@@ -360,6 +353,22 @@ class backup_migrate_destination_db_mysql extends backup_migrate_destination_db
   }
 
   /**
+   * Escape the row data and return an array of values ready for db insert.
+   */
+  function _db_prepare_row($row) {
+    // Escape backslashes, PHP code, special chars
+    $search = array('\\', "'", "\x00", "\x0a", "\x0d", "\x1a");
+    $replace = array('\\\\', "''", '\0', '\n', '\r', '\Z');
+
+    $items = array();
+    foreach ($row as $key => $value) {
+      $items[] = is_null($value) ? "null" : "'". str_replace($search, $replace, $value) ."'";
+    }
+
+    return $items;
+  }
+
+  /**
    * Get the db connection for the specified db.
    */
   function _get_db_connection() {
