Skip to content

Instantly share code, notes, and snippets.

@psynaptic
Created June 13, 2012 11:01
Show Gist options
  • Select an option

  • Save psynaptic/2923440 to your computer and use it in GitHub Desktop.

Select an option

Save psynaptic/2923440 to your computer and use it in GitHub Desktop.
#!/usr/bin/env php
<?php
// User configuration settings.
$user_prefix = 'psy_';
$sql = '/home/rburford/bash_kit/bin/sql.sh';
$database = 'examiner_dev';
// Import global settings.custom.php.
include('/home/rburford/public_html/settings.custom.php');
foreach ($databases['default']['default']['prefix'] as $table => $prefix) {
// If the prefix starts with the user-defined prefix...
if (strpos($prefix, $user_prefix) === 0) {
$source = $table;
$destination = $user_prefix . 'staging_' . $table;
// Clone the table.
system("$sql clone-table $database $source $destination");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment