Execute PHP Script (Class) as Cron

Hi guys,

I have a class ‘Get_Orders_Into_Database_Cron.php’ and inside a have a lots of functions.
But, in one function I want to insert orders into the database table, and have standard OXID code:
$oDb = oxDb::getDb();
But, when I am trying to execute the class via terminal and then set-up as a cron:
php Get_Orders_Into_Database_Cron.php I am getting following error:
Fatal error: Class ‘oxDb’ not found in /home/shop-name/Get_Orders_Into_Database_Cron.php on line 158

I tried with following line at the top of the script:
require_once ZMB_DIR_ROOT . ‘/lib/autoload.php’;

Any help how to load OXID classes in the file or extend them and then to be able to execute the class via terminal.

Thank you!

As far as I know, there is no oxDb in v6 anymore. The database class was changed.

Sorry, but I didn’t mention that I was working on v4.
But the problem is resolved, I loaded the whole oxid classes and functions by loading /bin/cron.php file.

Thanks for your help.

including whole bin/cron.php will not only run your own scripts, but also all the tasks of bin/cron.php like updating upcoming prices in shop.

For accessing oxid classes and functions you only need to include bootstrap.php