The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
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? |
#2
|
||||
|
||||
i have to go out for a few hours but i'll write the code for you when i come back
|
#3
|
|||
|
|||
Quote:
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. |
#4
|
|||
|
|||
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.. |
#5
|
|||
|
|||
Quote:
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. |
#6
|
|||
|
|||
[sql]UPDATE user SET contributionpoints=posts + helppoints * 3;[/sql]
|
#7
|
|||
|
|||
Quote:
It is definitly this simple. I'm shocked. Thanks a bunch, I was thinking about much more difficult solutions. |
#8
|
|||
|
|||
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. |
#9
|
|||
|
|||
Quote:
It working like a charm now. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|