I am trying to create a cron job while taking advantage of my current CI setup and the use of Controllers and Models. I am using Cron Bootstrapper (http://codeigniter.com/wiki/Cron_job_bootstrapper/) because it gives me easy access to test the process locally on-demand or be available as a traditional cron process on a server. I can reach the controller using the bootstrapper file and the command line, however, I am getting many different error messages or alerts depending on how I set up my controller.
If I keep the controller as it should be with parent::Controller();, I get the following message:
Unable to connect to your database server using the provided settings.
The error is coming from the DB_driver.php initialize() method.
If I remove the call to parent::Controller() from the controller then I get the following alert:
<p>Severity: Warning</p>
<p>Message: date(): It is not safe to rely on the system's timezone settings. You
are *required* to use the date.timezone setting or the
date_default_timezone_set() function. In case you used any of those
methods and you are still getting this warning, you most likely misspelled
the timezone identifier. We selected 'America/New_York' for
'EDT/-4.0/DST' instead</p>
<p>Filename: htdocs/cron.php</p>
<p>Line Number: 122</p>`
By removing the parent::Controller(); I am not able to access any models via $this->load->model('model'); and I get the following message:
Fatal error: Call to a member function model() on a non-object in /Applications/MAMP/htdocs/my_site/system/application/controllers/cron.php on line 9
Any info that will allow me to use the bootstrapper file with CI will be very helpful.
Set $db[‘default’][‘db_debug’] = TRUE; in your database config file to enable more verbose error reporting.
You need to heed the timezone warning and set a default in your php.ini file. This is a new requirement as of PHP 5.3. If you are running on a shared server and do not have access to php.ini, you can either request that your web host set a default value, or you can try setting it manually using ini_set() at the top of your bootstrap file.
Check and see if your database config file is being loaded, and if so, double-check your database connection settings. If the settings are right, there could be a firewall blocking you, or the database user you are connecting with might not have permission to access the database you are trying to use.