#!/usr/bin/env php $data) { // Remove descriptions to save time and code. unset($data['description']); foreach ($data['fields'] as &$field) { unset($field['description']); } // Dump the table structure. $output .= "db_create_table('" . $table . "', " . drupal_var_export($data) . ");\n"; // Don't output values for those tables. if (substr($table, 0, 5) == 'cache' || $table == 'sessions' || $table == 'watchdog') { $output .= "\n"; continue; } // Prepare the export of values. $result = db_query('SELECT * FROM {'. $table .'}', array(), array('fetch' => PDO::FETCH_ASSOC)); $insert = ''; foreach ($result as $record) { $insert .= '->values('. drupal_var_export($record) .")\n"; } // Dump the values if there are some. if ($insert) { $output .= "db_insert('". $table . "')->fields(". drupal_var_export(array_keys($data['fields'])) .")\n"; $output .= $insert; $output .= "->execute();\n"; } $output .= "\n"; } print $output;