Hi,
Frustrated right now. I'm creating a cron job in CodeIgniter.
Now, I have 2 folders inside my config directory, namely: development and testing and inside of it are the config files that are set for different environment, especially the database.php
The environment is set inside my .htaccess with the following code:
Please take note that my database (per environment):
And also, my current environment is set to "testing".
When I run a command, the error shows up:
The database driver is looking for the non-existing database (because the mydatabase_dev is located in my laptop, while the mydatabase_live is located in our production server and mydatabase_test is located in our test servers.
It is annoying. Can't figure out why this is happening. This only happens in CLI and in the browser it works fine.
Frustrated right now. I'm creating a cron job in CodeIgniter.
Now, I have 2 folders inside my config directory, namely: development and testing and inside of it are the config files that are set for different environment, especially the database.php
The environment is set inside my .htaccess with the following code:
Code:
<IfModule mod_env.c>
SetEnv CI_ENV testing
</IfModule>
Please take note that my database (per environment):
- development => 'mydatabase_dev'
- testing => 'mydatabase_test'
- production => 'mydatabase_live'
And also, my current environment is set to "testing".
When I run a command, the error shows up:
PHP Code:
A PHP Error was encountered
Severity: Warning
Message: mysqli::real_connect(): (HY000/1049): Unknown database 'mydatabase_dev'
Filename: C:/var/www/html/MY/system/database/drivers/mysqli/mysqli_driver.php
Line Number: 201
Backtrace:
File: C:/var/www/html/MY/application/core/CI_Exceptions.php
Line: 220
Function: include
File: C:/var/www/html/MY/application/core/CI_Controller.php
Line: 36
Function: __construct
File: C:/var/www/html/MY/application/controllers/Cron.php
Line: 53
Function: __construct
File: C:/var/www/html/MY/index.php
Line: 315
Function: require_once
Database error: A Database Error Occurred
Unable to connect to your database server using the provided settings.
Filename: core/CI_Controller.php
Line Number: 36
The database driver is looking for the non-existing database (because the mydatabase_dev is located in my laptop, while the mydatabase_live is located in our production server and mydatabase_test is located in our test servers.
It is annoying. Can't figure out why this is happening. This only happens in CLI and in the browser it works fine.