vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Creating a cronjob (https://vborg.vbsupport.ru/showthread.php?t=74927)

HakkieDEV 01-23-2005 01:37 PM

Creating a cronjob
 
Hi

Inside the table user I have 3 fields, posts and helppoints, contributionpoints.

Now, I would like to have a cronjob do every 24 hours a calculation like this:

$posts+$helppoints*3=$contributionpoints.

Now, it should update all contributionpoints fields in the table user.

And, like you've guessed, I have totally no idea how to do that. Anyone willing to help me a bit?

sabret00the 01-23-2005 01:42 PM

i have to go out for a few hours but i'll write the code for you when i come back :)

HakkieDEV 01-23-2005 01:44 PM

Quote:

Originally Posted by sabret00the
i have to go out for a few hours but i'll write the code for you when i come back :)

Now that is a fast response!

I know how to make queryes/update/insert/etc, but I have no idea how to select data from multiple fields, then do some modifications with it and then update the table again.

It would be really helpfull.

Thanks in advance. :)

miz 01-23-2005 01:50 PM

hmm
you mean use cornjob from admincp right ?

then write a php page that every time we run it its doing the update to query's
then just add it via admincp..

HakkieDEV 01-23-2005 02:01 PM

Quote:

Originally Posted by miz
hmm
you mean use cornjob from admincp right ?

then write a php page that every time we run it its doing the update to query's
then just add it via admincp..

Uhum, I know how to add a php file into the cronjob list in admincp.

I only have trouble in automating the process of selecting multiple fields and after modifications, inserting it again in multiple fields.

I know how to do it for a single field:

[sql]
$single= $DB_site->query("SELECT posts, helppoints FROM user WHERE userid=6");
$posts = $single['posts'];
$helppoints = $single['helppoints'];
$contributionpoints = $posts + $helppoints*3;
$update=$DB_site->query_first("UPDATE user SET contributionpoints=$contributionpoints WHERE userid=6");
[/sql]

However, this only works for 1 user per time.

I would like the same formula, but it should do this for ALL users.

Marco van Herwaarden 01-23-2005 05:15 PM

[sql]UPDATE user SET contributionpoints=posts + helppoints * 3;[/sql]

HakkieDEV 01-23-2005 05:19 PM

Quote:

Originally Posted by MarcoH64
[sql]UPDATE user SET contributionpoints=posts + helppoints * 3;[/sql]

Oh my god, tell me it isn't that simple? /me == stupid.

It is definitly this simple.

I'm shocked. :D

Thanks a bunch, I was thinking about much more difficult solutions.

Marco van Herwaarden 01-23-2005 06:01 PM

Yes it is that simple ;)

It will for each row take the rows value for posts and helppoints, multiply by 3, then store back in the contributepoints for that same row. You could add a WHERE clause if you want it to limit to only some users.

HakkieDEV 01-23-2005 06:16 PM

Quote:

Originally Posted by MarcoH64
Yes it is that simple ;)

It will for each row take the rows value for posts and helppoints, multiply by 3, then store back in the contributepoints for that same row. You could add a WHERE clause if you want it to limit to only some users.

Thanks a lot mate, I already inserted a WHERE clause.

It working like a charm now.


All times are GMT. The time now is 03:25 AM.

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.01452 seconds
  • Memory Usage 1,728KB
  • 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
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)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