You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.
HI Nick
Any idea why this block of code doesn't work inside a daily cron task
if (date('j') === '1') { $sql = 'SELECT id FROM core_users WHERE purchonacct='.$this->CORE_DB->quote(1); $accountlist= $this->CORE_DB->sql_do(array('sql' => $sql, 'table' => 'core_users', 'order' => array('id' => 'ASC'))); foreach ($accountlist as $num => $account) { $sql = 'SELECT sum(ordertotal) FROM ecom_orders WHERE email = '.$this->CORE_DB->quote($account['id']).' AND orderbalance<>' . $this->CORE_DB->quote('0.00').' AND statusinit=' . $this->CORE_DB->quote(1).' AND paymethod=' . $this->CORE_DB->quote('purchonacct'); $result=$this->CORE_DB->sql_do(array('sql' => $sql, 'table' => 'ecom_orders')); if ($result[0]['sum(ordertotal)']>0){ $this->exec_namespace(array('app' => 'ecom', 'namespace' => 'accountstatement', 'type' => '*', 'params' => $account['id'])); if ($this->debug) {$this->debugger("Sent Statement:".$account['id']);} } } }
I have just duplicated a similar cron job(which I have done before), changed the name, class name and $class.
It is supposed to check for 1st of month, and then send statements for a payonaccount accounts with an outstanding balance.
Code is inside function exec() and CORE_DB is declared.
Code works correctly if run outside of the cron task. so I know there are no errors in the code and the accountstatement namespace is set up correctly.
Offline