Jump to content

Can you help with DB update via cron please?


mr_absinthe

Recommended Posts

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...