vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Deleting Duplicate Threads That Do NOT Share The Same Timestamp (https://vborg.vbsupport.ru/showthread.php?t=201637)

TruthElixirX 01-13-2009 03:22 PM

Deleting Duplicate Threads That Do NOT Share The Same Timestamp
 
I need to delete some duplicate threads, but they do not have the same time stamp.

I opened up admincp/misc.php and went to:


Code:

        $threads = $db->query_read("
                SELECT threadid, title, forumid, postusername, dateline
                FROM " . TABLE_PREFIX . "thread WHERE threadid >= " . $vbulletin->GPC['startat'] . "
                ORDER BY threadid
                LIMIT " . $vbulletin->GPC['perpage']
        );

        $finishat = $vbulletin->GPC['startat'];

        while ($thread = $db->fetch_array($threads))
        {
                $deletethreads = $db->query_read("
                        SELECT *
                        FROM " . TABLE_PREFIX . "thread
                        WHERE title = '" . $db->escape_string($thread['title']) . "' AND
                                forumid = $thread[forumid] AND
                                postusername = '" . $db->escape_string($thread['postusername']) . "' AND
                                dateline = $thread[dateline] AND
                                threadid > $thread[threadid]
                ");


and changed it to (I removed what was colored blue above) :


Code:

        $threads = $db->query_read("
                SELECT threadid, title, forumid, postusername
                FROM " . TABLE_PREFIX . "thread WHERE threadid >= " . $vbulletin->GPC['startat'] . "
                ORDER BY threadid
                LIMIT " . $vbulletin->GPC['perpage']
        );

        $finishat = $vbulletin->GPC['startat'];

        while ($thread = $db->fetch_array($threads))
        {
                $deletethreads = $db->query_read("
                        SELECT *
                        FROM " . TABLE_PREFIX . "thread
                        WHERE title = '" . $db->escape_string($thread['title']) . "' AND
                                forumid = $thread[forumid] AND
                                postusername = '" . $db->escape_string($thread['postusername']) . "' AND
                                threadid > $thread[threadid]
                ");


This gets rid of the time stamp requirement, but now, I need to limit it to a specific username/id. How do I do this?

Bellardia 01-13-2009 03:30 PM

AND postuserid = $thread[postuserid]
but it's already limited by..
postusername = '" . $db->escape_string($thread['postusername']) . "'

TruthElixirX 01-13-2009 03:44 PM

Quote:

Originally Posted by Bellardia (Post 1711055)
AND postuserid = $thread[postuserid]
but it's already limited by..
postusername = '" . $db->escape_string($thread['postusername']) . "'

So I would put the username I wish to limit it to in

$thread['postusername']

So it would look like:

$thread['test']

for example?

Bellardia 01-13-2009 07:54 PM

$thread['test'] would have no value because there's no column 'test' on the thread database. You could just replace the whole string by
postusername = 'test' but depending on where you run the script it would always delete threads from test even if it was someone else's fault..

Where do you plan on placing this?

TruthElixirX 01-13-2009 08:14 PM

Quote:

Originally Posted by Bellardia (Post 1711344)
$thread['test'] would have no value because there's no column 'test' on the thread database. You could just replace the whole string by
postusername = 'test' but depending on where you run the script it would always delete threads from test even if it was someone else's fault..

Where do you plan on placing this?

I plan putting it in that section of admincp/misc.php and altering it for this one time use to cull some duplicate content, then reverting back to how it should be.


What do you mean by "would always delete threads from test even if it was someone else's fault." ?

Bellardia 01-13-2009 11:51 PM

Well I wasn't sure where you were pulling the code from.
It uses a variable as the username based on the thread that it's being performed on, so if you defined the name explicitly it would only work on threads based on the title of the thread you're using this on made by the user you've defined. Depending on how you do that it could be 0 threads.


All times are GMT. The time now is 03:48 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01070 seconds
  • Memory Usage 1,730KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete