mr_absinthe Posted November 19, 2018 Share Posted November 19, 2018 Hello, can someone help me to achieve a DB monthly update via cron job? The below code is quite self explanatory what I'm trying to achieve but no luck so far... 🙁 <?php //Set some common items $year = date("y"); $month = date("m"); //change order ID $sql = new DbQuery(); $sql = "ALTER TABLE '._DB_PREFIX_.'orders AUTO_INCREMENT=".$year.$month."001;"; return Db::getInstance()->executeS($sql); ?> The idea is to run the cron job on the 1st of each month. Link to comment Share on other sites More sharing options...
El Patron Posted November 24, 2018 Share Posted November 24, 2018 if you need code/approach for building a cron job within a module take a look at google sitemap module as an example. There you can see how a cron can be handled at module level. hope this help. Link to comment Share on other sites More sharing options...
mr_absinthe Posted November 25, 2018 Author Share Posted November 25, 2018 Thank you for your answer, here is the working solution if someone needs it as well. <?php require_once('./config/config.inc.php'); //Set some common items $year = date("y"); $month = date("m"); //change order ID $sql = "ALTER TABLE " . _DB_PREFIX_ . "orders AUTO_INCREMENT=".$year.$month."000;"; Db::getInstance()->execute($sql); ?> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now