PDA

View Full Version : [SLOVED] The difference between today's date and the date of the creation of Thread


omardealo
03-29-2013, 03:10 PM
HELLO ...

i make new filed in table thread .. and i want SET or UPDATE data of this filed After some days

LIKE THIS :

if (today's date (TIMENOW) - creation of Thread (dateline) >= 30 days)
{
SET or UPDATE thisfiled in thread table to (new data)
}


Do I need to use SQL QUERY OR there is a simple code for that
and what's name of hook to this plugin ...

i use this code but not work ... in global_start hook

$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . " thread
SET user_contact = 'anything'
WHERE
dateline <= ' . intval(TIMENOW - (60 * 60 * 24 * ".$vbulletin->options['user_contact_time'].")).'
");



I have another question here about same filed
https://vborg.vbsupport.ru/showthread.php?t=296543


Thank you !

kh99
03-29-2013, 04:45 PM
You have a couple of problems with that code. Try this:

$cutoff = TIMENOW - (60 * 60 * 24 * $vbulletin->options['user_contact_time']);
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "thread
SET user_contact = 'anything'
WHERE dateline <= $cutoff
");



As for where to put it, it might work at global_start, but I don't think you want it to run every time anyone accesses any page. You could use cron_script_cleanup_hourly and have it run once per hour, if that works for you.

omardealo
03-29-2013, 05:07 PM
Exactly , I do not want it running SQL QUERY all day , that's Will happen over load to Server
but I do not know much about the cron of vb ... can u help me for that (Is there any thread link talk about explanation run this code once every 24 hours or every hour)
and i Ask from you to consider on this topic, there is simple question but important for me
https://vborg.vbsupport.ru/showthread.php?t=296543

thnx u very much the code now Works well


if ($vbulletin->options['user_contact_onoff'])
{
$cutoff = TIMENOW - (60 * 60 * 24 * $vbulletin->options['user_contact_time']);
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "thread
SET user_contact = 'anything'
WHERE dateline <= $cutoff
AND
(user_contact != 'anything' OR user_contact IS NOT NULL)
");

}

kh99
03-29-2013, 05:20 PM
You should be able to have it run once per hour or day just by changing the hook location of your plugin: cron_script_cleanup_daily = once per day, cron_script_cleanup_hourly = once per hour. Note that those don't run at exact times, it will depend on how much activity your forum has.

omardealo
03-29-2013, 05:28 PM
You should be able to have it run once per hour or day just by changing the hook location of your plugin: cron_script_cleanup_daily = once per day, cron_script_cleanup_hourly = once per hour. Note that those don't run at exact times, it will depend on how much activity your forum has.

I understand now, sorry I thought you speak for cron system in vbulletin ...
Well, i will use this hooks ... Thanks again
Do not forget to consider this topic
https://vborg.vbsupport.ru/showthread.php?t=296543