Welcome Guest, Not a member yet? Register   Sign In
Environment affecting the configuration files in CLI mode
#1

(This post was last modified: 07-17-2018, 12:05 AM by kaitenz.)

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:
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'
(I changed the names due to confidentiality, sorry)

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
:
 
       FileC:/var/www/html/MY/application/core/CI_Exceptions.php
        Line
220
        Function
: include

 
       FileC:/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 errorA Database Error Occurred

        Unable to connect to your database server using the provided settings
.
 
       Filenamecore/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.
Reply


Messages In This Thread
Environment affecting the configuration files in CLI mode - by kaitenz - 07-16-2018, 08:54 PM



Theme © iAndrew 2016 - Forum software by © MyBB