bleem (March 28th, 2014)
<?php $serv="localhost"; $user="db_user"; $pass="dbpassword"; $base="db_name"; @mysql_connect($serv, $user, $pass) or exit("Fehler bei Verbindung zur Datenbank: $serv $user<br />"); @mysql_select_db($base) or exit("Datenbank $base nicht vorhanden<br />"); // Einstellung: SQL-Fehler*meldungen anzeigen $showsqlerrors=true; // Ausgabe einer Fehler*meldung und Abbruch function sqlExit($sql) { global $showsqlerrors; if ($showsqlerrors) echo "Fehler in SQL-Kommando: $sql<br />".mysql_error()."<br />\n"; exit(); } // Alte Anzeigen loeschen $loeschen = "DELETE FROM wp_posts WHERE post_type = 'job_listing'"; $loesch = mysql_query($loeschen); $loeschen = "DELETE FROM wp_posts WHERE post_status = 'future'"; $loesch = mysql_query($loeschen); $loeschen = "DELETE FROM wp_posts WHERE post_status = 'trash'"; $loesch = mysql_query($loeschen); $loeschen = "DELETE FROM wp_posts WHERE post_status = 'expired'"; $loesch = mysql_query($loeschen); // Unbenutzte Term Relationships und Taxonomien loeschen $loeschen = "DELETE tr FROM wp_term_relationships tr INNER JOIN wp_term_taxonomy tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id) WHERE tt.taxonomy != 'link_category' AND tr.object_id NOT IN (SELECT ID FROM wp_posts)"; $loesch = mysql_query($loeschen); $loeschen = "DELETE FROM wp_term_relationships WHERE NOT EXISTS (SELECT * FROM wp_posts WHERE wp_term_relationships.object_id = wp_posts.ID)"; $loesch = mysql_query($loeschen); $loeschen = "DELETE FROM wp_term_taxonomy WHERE count = '0'"; $loesch = mysql_query($loeschen); // Unbenutzte Postmeta Daten loeschen $loeschen = "DELETE FROM wp_postmeta WHERE post_id NOT IN (SELECT ID FROM wp_posts)"; $loesch = mysql_query($loeschen); // Unbenutzte Post Tags loeschen $loeschen = "DELETE FROM wp_terms WHERE term_id IN (SELECT term_id FROM wp_term_taxonomy WHERE count = 0 )"; $loesch = mysql_query($loeschen); $loeschen = "DELETE FROM wp_term_taxonomy WHERE term_id not IN (SELECT term_id FROM wp_terms)"; $loesch = mysql_query($loeschen); $loeschen = "DELETE FROM wp_term_relationships WHERE term_taxonomy_id not IN (SELECT term_taxonomy_id FROM wp_term_taxonomy)"; $loesch = mysql_query($loeschen); // Feed Cache loeschen $loeschen = "DELETE FROM `wp_options` WHERE `option_name` LIKE ('_transient%_feed_%')"; $loesch = mysql_query($loeschen); // Revisions loeschen $loeschen = "DELETE FROM wp_posts WHERE post_type = 'revision'"; $loesch = mysql_query($loeschen); // Abbruch, falls SQL-Kommando fehlerhaft function sqlQuery($sql) { $result=mysql_query($sql) or sqlExit($sql); return $result; } ?>
bleem (March 28th, 2014)
There are currently 1 users browsing this thread. (0 members and 1 guests)