View Full Version : update after 24 hours

02-26-2012, 07:43 AM
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:

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

my 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 ?

02-26-2012, 10: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

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum