AnonymousUser Posted August 27, 2012 Posted August 27, 2012 I want to set up my Donator Bank to interest users based upon ones donationdays and vipdays. Players who have just ddays and no vip will max at 2% along with only a 500m max interest and vip will be double if they have both vip and ddays then it should be maxed at 6% and maxed interest is 1.5b?? ie. users with 1 donator days get .05 percent interest/vip gain .1 interest per vip day Quote
sniko Posted August 27, 2012 Posted August 27, 2012 UPDATE `users` SET `bankmoney` = LEAST (`bankmoney`+ (`bankmoney` / 100) * 0.2, 500000000) WHERE (`bankmoney` > 0) AND (`donatordays` > 0) AND (`vip_days` <= 0) UPDATE `users` SET `bankmoney` = LEAST ( `bankmoney`+(`bankmoney` / 100) * 0.6, 1500000000) WHERE (`bankmoney` > 0) AND (`donatordays` > 0) AND (`vip_days` > 0) I believe that should work. Untested. 2 Quote
Octarine Posted August 27, 2012 Posted August 27, 2012 (edited) Why lock the users table twice when one query is sufficient? Edited August 27, 2012 by Octarine 1 Quote
AnonymousUser Posted August 27, 2012 Author Posted August 27, 2012 cool sniko ill give it a try and see how it goes :) Quote
AnonymousUser Posted August 27, 2012 Author Posted August 27, 2012 (edited) QUERY ERROR: FUNCTION ****_****.LEAST does not exist heres what im using for the code.... $db->query("UPDATE `users` SET `donatormoney` = LEAST (`donatormoney`+ (`donatormoney` / 100) * 0.2, 500000000) WHERE (`bankmoney` > 0) AND (`donatordays` > 0) AND (`vipdays` <= 0)"); $db->query("UPDATE `users` SET `donatormoney` = LEAST ( `donatormoney`+(`donatormoney` / 100) * 0.6, 1500000000) WHERE (`bankmoney` > 0) AND (`donatordays` > 0) AND (`vipdays` > 0)"); Edited August 27, 2012 by AnonymousUser Quote
sniko Posted August 27, 2012 Posted August 27, 2012 QUERY ERROR: FUNCTION ****_****.LEAST does not exist heres what im using for the code.... $db->query("UPDATE `users` SET `donatormoney` = LEAST (`donatormoney`+ (`donatormoney` / 100) * 0.2, 500000000) WHERE (`bankmoney` > 0) AND (`donatordays` > 0) AND (`vipdays` <= 0)"); $db->query("UPDATE `users` SET `donatormoney` = LEAST ( `donatormoney`+(`donatormoney` / 100) * 0.6, 1500000000) WHERE (`bankmoney` > 0) AND (`donatordays` > 0) AND (`vipdays` > 0)"); What version of MYSQL are you running? Quote
sniko Posted August 27, 2012 Posted August 27, 2012 looks like its 5.0.95 0 row(s) affected. ( Query took 0.0012 sec ) Version 5.5.8 Try updating version? Quote
HauntedDawg Posted August 27, 2012 Posted August 27, 2012 UPDATE `users` SET `bankmoney` = IF(`vip_days` <= 0, LEAST(`bankmoney` + (`bankmoney` / 100) * 0.2, 500000000), LEAST(`bankmoney` + (`bankmoney` / 100) * 0.6, 500000000)) WHERE `bankmoney` AND `donatordays`; If any error, post it up. Quote
AnonymousUser Posted August 27, 2012 Author Posted August 27, 2012 @haunted i though we established my version dont have the 'least' function @sniko unfortunately no luck Quote
HauntedDawg Posted August 27, 2012 Posted August 27, 2012 "Before MySQL 5.0.13, LEAST() returns NULL only if all arguments are NULL. As of 5.0.13, it returns NULL if any argument is NULL. " RT(F)M! http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#function_least 1 Quote
AnonymousUser Posted August 27, 2012 Author Posted August 27, 2012 actually that worked haunted! lol thanks a bunch... +1 for u and +1 for sniko for trying :) thanks again guys now i just gotta add to my donatorbank to say how much interest they're getting :p Quote
sniko Posted August 27, 2012 Posted August 27, 2012 actually that worked haunted! lol thanks a bunch... +1 for u and +1 for sniko for trying :) thanks again guys now i just gotta add to my donatorbank to say how much interest they're getting :p Ah good to hear! Quote
AnonymousUser Posted August 30, 2012 Author Posted August 30, 2012 but it looks like its updating the users donator bank to where if they have 'max interest' its setting there total bank amount to the max interest instead of giving it to them lol $db->query(" UPDATE `users` SET `donatormoney` = IF(`vipdays` <= 0, LEAST(`donatormoney` + (`donatormoney` / 100) * 0.2, 500000000), LEAST(`donatormoney` + (`donatormoney` / 100) * 0.6, 500000000)) WHERE `donatormoney` AND `donatordays`"); Quote
Djkanna Posted August 30, 2012 Posted August 30, 2012 but it looks like its updating the users donator bank to where if they have 'max interest' its setting there total bank amount to the max interest instead of giving it to them lol $db->query(" UPDATE `users` SET `donatormoney` = IF(`vipdays` <= 0, LEAST(`donatormoney` + (`donatormoney` / 100) * 0.2, 500000000), LEAST(`donatormoney` + (`donatormoney` / 100) * 0.6, 500000000)) WHERE `donatormoney` AND `donatordays`"); $db->query("UPDATE `users` SET `donatormoney` = `donatormoney` + IF(`vipdays` <= 0, LEAST(`donatormoney` + (`donatormoney` / 100) * 0.2, 500000000), LEAST(`donatormoney` + (`donatormoney` / 100) * 0.6, 500000000)) WHERE `donatormoney` AND `donatordays`"); Forgive spelling errors for column names. 1 Quote
AnonymousUser Posted September 4, 2012 Author Posted September 4, 2012 no worries lol thanks DJK as always ya pull through :) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.