Jump to content

Recommended Posts

Hi,

 

I want this to run only once every 5 days or greater.

 

The problem is, it is running every time the page is opened.

 

It updates the last_modified field but not the configuration_value field.

 

Can anyone help with this please.

 

<?php

  $prev = tep_db_query("select * from " . TABLE_CONFIGURATION . " where configuration_key = 'CRON_BD_RUN'");
  if (tep_db_num_rows($prev) > 0) {
  $prev_val = tep_db_fetch_array($prev);
  if($prev_val['configuration_value'] <= (date("Ymd") - 5)) {
echo 'Test Code';      
            tep_db_query("UPDATE " . TABLE_CONFIGURATION . " SET configuration_value = '" . date("Ymd") . "', last_modified = now() WHERE configuration_key = 'CRON_BD_RUN'"); 
        
          }
       } else {
         tep_db_query("INSERT INTO ".TABLE_CONFIGURATION." (CONFIGURATION_KEY, configuration_value, CONFIGURATION_GROUP_ID) VALUES('CRON_BD_RUN', '".date("Ymd")."', 6)");
  }

?>

 

CREATE TABLE IF NOT EXISTS `osc_configuration` (
  `configuration_id` int(11) NOT NULL auto_increment,
  `configuration_title` varchar(255) collate utf8_unicode_ci NOT NULL,
  `configuration_key` varchar(255) collate utf8_unicode_ci NOT NULL,
  `configuration_value` varchar(255) collate utf8_unicode_ci NOT NULL,
  `configuration_description` varchar(255) collate utf8_unicode_ci NOT NULL,
  `configuration_group_id` int(11) NOT NULL,
  `sort_order` int(5) default NULL,
  `last_modified` datetime default NULL,
  `date_added` datetime NOT NULL,
  `use_function` varchar(255) collate utf8_unicode_ci default NULL,
  `set_function` varchar(255) collate utf8_unicode_ci default NULL,
  PRIMARY KEY  (`configuration_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=201 ;

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.