Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-26-2012, 06:43 AM   PM User | #1
bijaybd
New Coder

 
Join Date: Nov 2008
Posts: 99
Thanks: 4
Thanked 0 Times in 0 Posts
bijaybd has a little shameless behaviour in the past
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 ?
__________________
[size=large]TipsGlobe.Com[/size]

Last edited by bijaybd; 02-26-2012 at 09:08 AM..
bijaybd is offline   Reply With Quote
Old 02-26-2012, 09:09 AM   PM User | #2
bijaybd
New Coder

 
Join Date: Nov 2008
Posts: 99
Thanks: 4
Thanked 0 Times in 0 Posts
bijaybd has a little shameless behaviour in the past
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
__________________
[size=large]TipsGlobe.Com[/size]
bijaybd is offline   Reply With Quote
Reply

Bookmarks

Tags
magento, php

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:40 PM.


Advertisement
Log in to turn off these ads.