• Resolved carvol

    (@carvol)


    Can someone help me to manage by cron, “Clean All” function for Database?
    I’ve found solution for cache, to purge all, but for DB – can’t.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support qtwrk

    (@qtwrk)

    unfortunately it doesn’t have option to cron it 🙁

    Thread Starter carvol

    (@carvol)

    Maybe, there is a way, to make a file whith script, that will make the same, as i push the button “Clean All”?

    Plugin Support qtwrk

    (@qtwrk)

    <?php
    require('./wp-load.php');

    global $wpdb;

    $wpdb->query("DELETE a FROM
    $wpdb->postmeta a LEFT JOIN $wpdb->posts b ON b.ID = a.post_id WHERE b.post_type = 'revision'");
    $wpdb->query("DELETE FROM $wpdb->posts WHERE post_type = 'revision'");
    $wpdb->query("DELETE a FROM $wpdb->postmeta a LEFT JOIN $wpdb->posts b ON b.ID = a.post_id WHERE b.ID IS NULL");
    $wpdb->query("DELETE FROM $wpdb->posts WHERE post_status = 'auto-draft'");
    $wpdb->query("DELETE FROM $wpdb->posts WHERE post_status = 'trash'");
    $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_approved = 'spam'");
    $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_approved = 'trash'");
    $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_type = 'trackback' OR comment_type = 'pingback'");
    $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '_transient_timeout%' AND option_value < " . time());
    $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '%\\_transient\\_%'");
    $result = $wpdb->get_results("SELECT table_name, DATA_FREE FROM information_schema.tables WHERE TABLE_SCHEMA = '" . DB_NAME . "' and ENGINE <> 'InnoDB' and DATA_FREE > 0");
    if ($result) {
    foreach ($result as $row) {
    $wpdb->query('OPTIMIZE TABLE ' . $row->table_name);
    }
    }

    echo "done";

    I extracted query from plugin , please note this is best-effort support , use it at your own risk and suggest to perform a backup and test first

    • This reply was modified 1 year, 3 months ago by qtwrk.
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘LSCWP Database’ is closed to new replies.