function clean_dead_comments() { global $wpdb, $table_prefix; $sql = sprintf("delete %s from %sgdsr_data_comment l left join %scomments o on o.comment_ID = l.comment_id where o.comment_ID is null", gdFunctionsGDSR::mysql_pre_4_1() ? sprintf("%sgdsr_data_comment", $table_prefix) : "l", $table_prefix, $table_prefix); $wpdb->query($sql); return $wpdb->rows_affected; }
function clean_dead_articles() { global $wpdb, $table_prefix; $sql = sprintf("delete %s from %sgdsr_multis_data l left join %sposts o on o.ID = l.post_id where o.ID is null", gdFunctionsGDSR::mysql_pre_4_1() ? sprintf("%sgdsr_multis_data", $table_prefix) : "l", $table_prefix, $table_prefix); $wpdb->query($sql); $posts = $wpdb->rows_affected; $sql = sprintf("delete %s from %sgdsr_multis_values l left join %sgdsr_multis_data o on o.id = l.id where o.id is null", gdFunctionsGDSR::mysql_pre_4_1() ? sprintf("%sgdsr_multis_values", $table_prefix) : "l", $table_prefix, $table_prefix); $wpdb->query($sql); return $posts; }