1
kerkyra
How to make a function similar to a cron job...
  • 2008/5/28 8:53

  • kerkyra

  • Just can't stay away

  • Posts: 553

  • Since: 2005/2/14


Hi,
i would like to make a function run once in a day and filter my dbs records, in order to make (according to some criteria) some of them inactive! For example i want to make a record inactive after a month it is submitted. I dont want to make a cron job right now! I was wandering if there is another way to do this! I noticed the catads module works like this and without making a cron job. Any ideas on how this could be achieved? Thanks
whttp://www.guidemap.gr - Beta is out...

2
kakos
Re: How to make a function similar to a cron job...
  • 2008/5/28 11:02

  • kakos

  • Friend of XOOPS

  • Posts: 79

  • Since: 2002/6/6 2


Recently I tried XoopsCare from Instant Zero. I think you should give it a try.
Some features:

1/ Maintain your database (check, repair, analyse and optimize your tables)
2/ Run you own queries when you want
3/ Execute Php code when you want it
4/ Clean templates_c and cache folders
5/ Remove spammed comments
6/ Clean sessions

The module can do its job with a cron or with its block.

Costas

3
kerkyra
Re: How to make a function similar to a cron job...
  • 2008/5/28 13:25

  • kerkyra

  • Just can't stay away

  • Posts: 553

  • Since: 2005/2/14


i'll give it a try mate! thanks! Although i wanted to make my module independent of any other, but this will do the job for now

Thanks
whttp://www.guidemap.gr - Beta is out...

4
kerkyra
Re: How to make a function similar to a cron job...
  • 2008/5/28 14:19

  • kerkyra

  • Just can't stay away

  • Posts: 553

  • Since: 2005/2/14


hey, i did instal xoopscare, i'm trying to run the following php code but with no results...
Quote:

$today = time();
$result1 = $xoopsDB->query("select lid, expdate from ".$xoopsDB->prefix("addresses_links")." WHERE status>0 AND expdate>0");
while(list($lid, $expdate) = $xoopsDB->fetchRow($result1)) {
if ($expdate>=$today) {
$sql= sprintf("UPDATE %s SET status = 0 WHERE lid= %u", $xoopsDB->prefix("addresses_links"),$lid);
$xoopsDB->query($sql) or $eh->show("0013");
}

}


does it recognise the XOOPS classes? how should i enter the code i want to run?
right now it executes the code but does nothing!
whttp://www.guidemap.gr - Beta is out...

5
kerkyra
Re: How to make a function similar to a cron job...
  • 2008/5/28 20:08

  • kerkyra

  • Just can't stay away

  • Posts: 553

  • Since: 2005/2/14


anybody??
whttp://www.guidemap.gr - Beta is out...

6
kerkyra
Re: How to make a function similar to a cron job...
  • 2008/5/29 12:25

  • kerkyra

  • Just can't stay away

  • Posts: 553

  • Since: 2005/2/14


any help on the subject??
whttp://www.guidemap.gr - Beta is out...

7
trabis
Re: How to make a function similar to a cron job...
  • 2008/5/29 12:32

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Do a echo $sql to see if the querie is alright;

if not, try adding
global $xoopsDB;

Is there any error log by the way?

8
kerkyra
Re: How to make a function similar to a cron job...
  • 2008/5/29 14:09

  • kerkyra

  • Just can't stay away

  • Posts: 553

  • Since: 2005/2/14


no error logs whatsoever! if i try to just echo the time() variable it works fine! if i add the sql statement and try to echo it, it does nothing! It doesnt even echo time which is added in the second line of the code! The global xoopsDB statement seems to do nothing as well. Any ideas are welcomed... :(
whttp://www.guidemap.gr - Beta is out...

9
mboyden
Re: How to make a function similar to a cron job...
  • 2008/5/29 16:46

  • mboyden

  • Moderator

  • Posts: 484

  • Since: 2005/3/9 1


The php code for XoopsCare runs independent of XOOPS, so I don't see how you would expect to access the XOOPS variables.

Doing a brief look at your code, I would suggest that you just re-write the code in SQL and use that part of XoopsCare instead. The tool works and can run the various pieces of code, but best I can tell it runs outside of the XOOPS environment because it's called by the account on the server under a cron job.

So, for MySQL, if you can successfully run the commands in phpMyAdmin for your XOOPS database, then you'll be able to run the same code inside this module.

Same for php. If you can run it from the command line as the user that will run the cron job, then XoopsCare will run it.

Clear as mud?
Pessimists see difficulty in opportunity; Optimists see opportunity in difficulty. --W Churchill

XOOPS: Latest | Debug | Hosting and Web Development

10
kerkyra
Re: How to make a function similar to a cron job...
  • 2008/5/30 7:49

  • kerkyra

  • Just can't stay away

  • Posts: 553

  • Since: 2005/2/14


i see! thanks for your help! i'll modify the code and get back to you if any probs! Thanks mate!
whttp://www.guidemap.gr - Beta is out...

Login

Who's Online

427 user(s) are online (336 user(s) are browsing Support Forums)


Members: 0


Guests: 427


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits