Welcome Guest, Not a member yet? Register   Sign In
Call session inside Config/Databases.php
#1

(This post was last modified: 05-03-2020, 05:40 PM by wesleysiqueira.)

When i used ci3 i used like this:
Code:
$ci =& get_instance();

and then
Code:
$ci->session->userdata();


to clarify i wold like to load databases dynamically based on my encrypted session.

Rigth now i have : 
Code:
    public $default = [
        'DSN'      => '',
        'hostname' => 'localhost',
        'username' => 'root',
        'password' => '',
        'database' => '', // I WOULD LIKE TO CHANGE THIS DYNAMICALLY BUT IN CI4 I DON'T KNOW HOW TO DO. LIKE: $THIS->SESSION->GET('COMPANY');
        'DBDriver' => 'MySQLi',
        'DBPrefix' => '',
        'pConnect' => false,
        'DBDebug'  => (ENVIRONMENT !== 'production'),
        'cacheOn'  => false,
        'cacheDir' => '',
        'charset'  => 'utf8',
        'DBCollat' => 'utf8_general_ci',
        'swapPre'  => '',
        'encrypt'  => false,
        'compress' => false,
        'strictOn' => false,
        'failover' => [],
        'port'     => 3306,
    ];



But now with ci4 i don't know how to do. Anyone can help me? Smile
Reply




Theme © iAndrew 2016 - Forum software by © MyBB