Welcome Guest, Not a member yet? Register   Sign In
Unload Database
#1

Hi all, 
I'd like to "unload" Database because I don't need it and, most of all, I don't want to use a local db just to avoid the "db connection error" at the bootstrap. 
I'm using CodeIgniter 4.

Many thanks,
Maui
Reply
#2

(This post was last modified: 12-16-2021, 09:52 PM by kenjis.)

Where did you load database?
Reply
#3

(This post was last modified: 12-17-2021, 05:22 AM by maui82.)

(12-16-2021, 09:50 PM)kenjis Wrote: Where did you load database?

it's hard to say because in CI3 I used to load libraries in the autoload.php file: 

Code:
$autoload['libraries'] = array('database', 'session', 'email');


But in CI4 (which I'm using now for the first time) the autoload.php file is slightly different and only contains the following lines (I cut the comments out):

Code:
<?php
namespace Config;
use CodeIgniter\Config\AutoloadConfig;

class Autoload extends AutoloadConfig
{
    public $psr4 = [
        APP_NAMESPACE => APPPATH, [i]// For custom app namespace[/i]
        'Config'      => APPPATH . 'Config',
    ];
    public $classmap = [];
}


I don't know exactly where the database is loaded (but it is, because everything works fine if I define an access in the .env file or in the /app/Config/Database.php)
Reply
#4

@maui82,

Try setting an incorrect password and see if errors or warnings appear.
Reply
#5

The connection to the database is made on the first request to the database.
Don't want to connect? Do not make inquiries into it.

In CI3, autoloading meant pre-linking libraries. In order not to be distracted by initialization while the application is running.
Reply
#6

(12-18-2021, 05:33 AM)iRedds Wrote: The connection to the database is made on the first request to the database.
Don't want to connect? Do not make inquiries into it.

In CI3, autoloading meant pre-linking libraries. In order not to be distracted by initialization while the application is running.



This helped me solving the problem: the database was loaded in a model.
I removed all the queries and now I don't get any connection error if the db is not reachable.
Thank you very muchs!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB