开发者

CodeIgniter without a Database?

开发者 https://www.devze.com 2023-01-10 01:13 出处:网络
Sorry if this is a simple question, is it possible to load codeigniter without a db setup? I have sess_use_db set to false in the config, I tried renaming database.php to something else but it still

Sorry if this is a simple question, is it possible to load codeigniter without a db setup?

I have sess_use_db set to false in the config, I tried renaming database.php to something else but it still wants to load it, I turned active records off also.

I tried commenting everything out in the database.php and it said no database settings fou开发者_运维知识库nd, autoload doesn't load the db.

Is this even possible?


Theoretically, there should be no reason that CI needs a database. sess_use_db=false just stops CI from storing it's session information in a database. Check that you are not autoloading the database files in config/autoload.php

You could set the database type to 'sqlite' in config/database.php if you simply want to avoid setting up mysql, but you will need to have sqlite installed.

HTH


You just need to remove or comment the following line from autoload.php file in config folder:

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


I think you should check your $autoload['libraries'] and remove database.


By default, CodeIgniter does not use the database at all.


Remove or comment $autoload['libraries'] = array('database', 'session');

in autoload.php. This will enable Code Igniter to load without using database


I would have thought so. I don't see why you then wouldn't be able to hard-code data within your models.


I know its an old thread but answers for a clearer answer.

You need to check in two places config.php and autoload.php as the website depends on two things which depend on database, which are autoload 'database' & 'sessions' which we need to remove.

But for sessions, rather than eliminating it from autoload, we can keep it by just changing its configuration setting.

In Config.php : you need to modify 'session' settings by changing its driver to:

$config['sess_driver'] = 'files'; .

In autoload.php : you need to modify the 'library' by removing "database" :

$autoload['libraries'] = array('session', 'form_validation');

Also, do make sure that your site doesn't have any funtions calling for database.

That should fix your issues.


You need to remove database from config/autoload.php

Current:

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

Then remove database:

$autoload['libraries'] = array('session');
0

精彩评论

暂无评论...
验证码 换一张
取 消