Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Nov 2008
    Posts
    103
    Thanks
    4
    Thanked 0 Times in 0 Posts

    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 ?
    Last edited by bijaybd; 02-26-2012 at 10:08 AM.

  • #2
    Regular Coder
    Join Date
    Nov 2008
    Posts
    103
    Thanks
    4
    Thanked 0 Times in 0 Posts
    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


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •