CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   PHP (http://www.codingforums.com/forumdisplay.php?f=6)
-   -   update after 24 hours (http://www.codingforums.com/showthread.php?t=252661)

bijaybd 02-26-2012 06:43 AM

update after 24 hours
 
I am using magento.well, i have a database where i store users points now i want to run a query like :
get time from database points where id=$id

now i have the last time points data has been updated. So, if the data updated more then 24 hours then a new query will run and update 50 points and time of the data. Can anybody help me on that how to code it. I tried but stuck and failed. Even a example will be great.

here is my code that i have tried but no results :

well have also tested results though echo : results:

Code:

$time_current = 1330240954
$utime = 1330240832
$refresh = 10

my code:
PHP Code:

    $table $resource->getTableName('points');
    
$query 'SELECT points FROM ' $table ' WHERE user_id = '. (int)$cidvar .' LIMIT 1';


    
$time_current time();
    
$time_updates_last 'SELECT time FROM ' $table ' WHERE user_id = '. (int)$cidvar .' LIMIT 1'
    
$utime $readConnection->fetchOne($time_updates_last); 
    
$refresh 10// example time set to be 10 seconds but orginal has to be 24 hours or 86400 seconds
    
$data_age $time_current $utime;

if(
$data_age >= $refresh){ 
   
$write Mage::getSingleton('core/resource')->getConnection('core_write');
    
$write->query("UPDATE points SET points = points + 20 AND time = '$time_current' where user_id ='. (int)$cidvar .' LIMIT 1");


where did i made the mistake or why its not updating ?

bijaybd 02-26-2012 09:09 AM

well the problem is solved all i need to do is making 2 queries 1 for points to be increased and one for time to be increased i guess magento only allowed these don't know but works for me i know it will create a lilttle bit load but didn't find any solution expect this


All times are GMT +1. The time now is 09:50 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.