Skip to content

Instantly share code, notes, and snippets.

@alOneh
Created December 22, 2011 11:13
Show Gist options
  • Save alOneh/1509940 to your computer and use it in GitHub Desktop.
Save alOneh/1509940 to your computer and use it in GitHub Desktop.
Script that use OnlineSchemaChange of Facebook
// do online schema change
$alter = "ALTER TABLE ".$tableName." ADD ".$description .";
try {
$osc = new OnlineSchemaChange($sock, $user, $pwd, $db, null, $alter);
// Return true on success or false on failure
return $osc->execute();
} catch (Exception $e) {
// exception raises only if cleanup fails
// In that case calls OSC again with FORCE_CLEANUP.
if (!empty($osc)) {
$osc->forceCleanup();
} else {
echo "Caught OSC constructor exception: ".$e->getMessage(). "\n";
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment