Skip to content

Instantly share code, notes, and snippets.

@brusch
Created February 18, 2016 13:57
Show Gist options
  • Save brusch/0644af7f63ddb792e495 to your computer and use it in GitHub Desktop.
Save brusch/0644af7f63ddb792e495 to your computer and use it in GitHub Desktop.
<?php
include("../../pimcore/cli/startup.php");
$db = Pimcore\Resource::get();
$tables = $db->fetchAll("SHOW TABLES LIKE 'object_localized_query_%'");
echo "\n\n";
foreach ($tables as $table) {
$t = current($table);
preg_match("/object_localized_query_([0-9]+)_/", $t, $matches);
$classId = $matches[1];
echo "Cleaning up " . $t . " ...";
$db->query("DELETE FROM " . $t . " WHERE ooo_id NOT IN (SELECT o_id FROM objects WHERE o_classId = " . $classId . ")");
echo "done!\n";
}
echo "\n\n";
echo "Done!";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment