The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
Comments |
#32
|
|||
|
|||
I cannot see what is wrong. There must be some code syntax we are not aware of as the query works fine manually. I did see that perhaps quotes were missing around the array element, but that doesn't seem to make a difference. Here's what I've got that shows some of what I've tried to make this work.
Code:
<?php require ("global.php"); $time = time() - (25 * 24 * 60 * 60); print "1168888543<br />"; print $time; print "<br />1170502241"; // $a = $DB_site->query("DELETE FROM privatemessage WHERE dateline < $time"); // $a = $DB_site->query_first("SELECT COUNT(*) AS oldpms FROM privatemessage WHERE dateline < $time"); // print "Total PMs To Be Deleted: $a[oldpms]"; // $a = $DB_site->query("DELETE FROM vbpm WHERE pmtextid IN(SELECT pmtextid FROM vbpmtext WHERE dateline < $time)); // $a = $DB_site->query("DELETE FROM vbpmtext WHERE pmtextid IN(SELECT pmtextid FROM vbpmtext WHERE dateline < $time)); $a = $db->query_read("SELECT COUNT(*) AS oldpms FROM vbul_pm WHERE pmtextid IN(SELECT pmtextid FROM vbul_pmtext WHERE dateline < $time)"); $b = $a[oldpms] + 1; $c = $a; print "<br />Total PMs To Be Deleted:<br />" . $a[1]; print $a['oldpms']; print $b . '<br />' . $c; if ($a['oldpms'] == 3) {print '<br />OK<br />'; } if ($a['oldpms'] <> 3) {print '<br />Not OK<br />'; } $a = $db->query_read("SELECT COUNT(*) AS oldpms FROM vbul_pmtext WHERE pmtextid IN(SELECT pmtextid FROM vbul_pmtext WHERE dateline < $time)"); print "Total PMtexts To Be Deleted:"; print $a[oldpms]; ?> |
#33
|
|||
|
|||
A hint on another forum got me closer.
Using this: Code:
<?php require ("global.php"); $time = time() - (25 * 24 * 60 * 60); // $a = $DB_site->query("DELETE FROM privatemessage WHERE dateline < $time"); // $a = $DB_site->query_first("SELECT COUNT(*) AS oldpms FROM privatemessage WHERE dateline < $time"); // print "Total PMs To Be Deleted: $a[oldpms]"; // $a = $DB_site->query("DELETE FROM vbpm WHERE pmtextid IN(SELECT pmtextid FROM vbpmtext WHERE dateline < $time)); // $a = $DB_site->query("DELETE FROM vbpmtext WHERE pmtextid IN(SELECT pmtextid FROM vbpmtext WHERE dateline < $time)); $a = $db->query_first("SELECT COUNT(*) AS oldpms FROM vbpm WHERE pmtextid IN(SELECT pmtextid FROM vbpmtext WHERE dateline < $time)"); print "<br />Total PMs To Be Deleted: "; print $a['oldpms']; $a = $db->query_first("SELECT COUNT(*) AS oldpms FROM vbpmtext WHERE pmtextid IN(SELECT pmtextid FROM vbpmtext WHERE dateline < $time)"); print "<br />Total PMtexts To Be Deleted: "; print $a['oldpms']; ?> Quote:
|
#34
|
|||
|
|||
It is normal that those two counts are different. The database is normalized, so the text of the PM only gets sent once, while the PM will have a count of 2, one for the inbox of receiver and one for the sentbox of the sender. The PMs would be exactly double if no one had deleted any, but with that many you'll have some where either the sender or receiver deleted, but not the other.
So the initial welcome PM on my system has this: PMID = 1, PMTextID=1,UserID=1,folderid=-1 PMID=2,PMTextID=1,UserID=1,folderid=0 The PM went from me to me, so the UserID is the same. One PM is in my sent items, and one is in my inbox, which must be what the folderid is referring to. They both have identical text, so they point to the same PMTextID. So that code looks fine. Now you need a query that will select and delete all the rows in vbpmreceipts where PMID = one of the PMIDs you are deleting. |
#35
|
|||
|
|||
Thanks, Jacqueline.
I've been soliciting some help over at TAZ as well and member Sarah there has suggested this: Quote:
|
#36
|
|||
|
|||
At first I tried these and they didn't work. Then I realized there were no read receipts on this forum yet, so I sent a message with one. The select count selected one. The delete I changed to a select and it selected the correct record, so it looks like she did a great job with the code for you.
|
#37
|
|||
|
|||
Here's the latest:
Code:
<?php require ("global.php"); $time = time() - (25 * 24 * 60 * 60); // $a = $DB_site->query("DELETE FROM privatemessage WHERE dateline < $time"); // $a = $DB_site->query_first("SELECT COUNT(*) AS oldpms FROM privatemessage WHERE dateline < $time"); // print "Total PMs To Be Deleted: $a[oldpms]"; // $a = $DB_site->query("DELETE FROM vbpm WHERE pmtextid IN(SELECT pmtextid FROM vbpmtext WHERE dateline < $time)); // $a = $DB_site->query("DELETE FROM vbpmtext WHERE pmtextid IN(SELECT pmtextid FROM vbpmtext WHERE dateline < $time)); $a = $db->query_first("SELECT COUNT(*) AS oldpms FROM vbpm WHERE pmtextid IN(SELECT pmtextid FROM vbpmtext WHERE dateline < $time)"); print "<br />Total PMs To Be Deleted: "; print $a['oldpms']; $a = $db->query_first("SELECT COUNT(*) AS oldpms FROM vbpmtext WHERE pmtextid IN(SELECT pmtextid FROM vbpmtext WHERE dateline < $time)"); print "<br />Total PM Texts To Be Deleted: "; print $a['oldpms']; $a = $db->query_first ("SELECT COUNT(*) AS oldpms FROM vbpmreceipt LEFT JOIN vbpm ON vbpm.pmid = vbpmreceipt.pmid LEFT JOIN vbpmtext ON vbpm.pmtextid = vbpmtext.pmtextid WHERE vbpmtext.dateline < $time"); print "<br />Total PM Receipts To Be Deleted: "; print $a['oldpms']; ?> Quote:
This is the result using "query_first". If I just use "query", no data is printed (just the text). What exactly is the difference? |
#38
|
|||
|
|||
Answering my own question, from https://vborg.vbsupport.ru/showthread.php?t=75207:
Quote:
Quote:
|
#39
|
|||
|
|||
So:
If I understand this now, the following tells me how many PMs, PM Texts, and PM Receipts need to be deleted: Code:
<?php require ("global.php"); $time = time() - (25 * 24 * 60 * 60); $a = $db->query_first("SELECT COUNT(*) AS oldpms FROM vbpm WHERE pmtextid IN(SELECT pmtextid FROM vbpmtext WHERE dateline < $time)"); print "<br />Total PMs To Be Deleted: "; print $a['oldpms']; $a = $db->query_first("SELECT COUNT(*) AS oldpms FROM vbpmtext WHERE pmtextid IN(SELECT pmtextid FROM vbpmtext WHERE dateline < $time)"); print "<br />Total PM Texts To Be Deleted: "; print $a['oldpms']; $a = $db->query_first ("SELECT COUNT(*) AS oldpms FROM vbpmreceipt LEFT JOIN vbpm ON vbpm.pmid = vbpmreceipt.pmid LEFT JOIN vbpmtext ON vbpm.pmtextid = vbpmtext.pmtextid WHERE vbpmtext.dateline < $time"); print "<br />Total PM Receipts To Be Deleted: "; print $a['oldpms']; ?> Code:
<?php require ("global.php"); $time = time() - (25 * 24 * 60 * 60); $a = $db->query("DELETE * FROM vbpm WHERE pmtextid IN(SELECT pmtextid FROM vbpmtext WHERE dateline < $time)"); $a = $db->query("DELETE * FROM vbpmtext WHERE pmtextid IN(SELECT pmtextid FROM vbpmtext WHERE dateline < $time)"); $a = $db->query("DELETE * FROM vbpmtext, vbpm, vbpmreceipt WHERE (vbpm.pmid = vbpmreceipt.pmid) AND (vbpm.pmtextid = vbpmtext.pmtextid)AND vbpmtext.dateline < $time"); ?> And do I need "DELETE *" or just "DELETE"? |
#40
|
|||
|
|||
I will take a look at this later tonight, but I just spotted that you've got the 25 days I was using instead of the 60 days you wanted in your time variable.
|
#41
|
|||
|
|||
I took a quick look at the delete statements and it doesn't look right. The delete * is right, but I do not see any where you are deleting from vbpmreceipt. The order matters too. Probably vbpmreceipts need to be deleted first, then vbpm, then vbpmtext. Once you delete vbpmtext, you lose your date and cannot use it to delete the others.
|
Thread Tools | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|