Database connection settings with DB_DEBUG set as FALSE

我们两清 提交于 2019-12-12 20:35:20

问题


I'm trying to connect to my database but i get the following message:

Unable to connect to your database server using the provided settings.

Filename: core/Loader.php

Line Number: 346

So after reading a lot, I found that setting $db['default']['db_debug'] to FALSE in database connection solves it. I did that and the error message disappeared; the website's first page loaded too but it had no database calls. From then on I started getting errors during my database calls, the query were possibly not returning query objectts.

So I want to know does DB_DEBUG actually solves the problem connection or it simply masks the problem that the DB connection errors do not show?


回答1:


I recommend you to set $db['default']['db_debug'] = TRUE while debug Mode.

In Application > Config > database.php set

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = '<ur username>'; // like 'root'
$db['default']['password'] = ',ur pwd.'; // like ''
$db['default']['database'] = '<db name>';

In Application > Config > autoload.php

load the database like,

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



回答2:


Please see this, i answered in another question:

I found why. In my situation, database error because my mysql config in php.ini is not right.

CI works well after I set mysql config in php.ini, like this:

[Mysql]
mysql.default_socket = /tmp/mysql.sock

If you didn't configure php.ini, the default socket is /var/mysql/mysql.sock, please check it.

I also set $db['default']['db_debug] to FALSE before, it looks ok, but no. It's just hide the error of mysql config, when I test to read from tables of mysql, I got nothing and didn't know why nothing. So I debug it, i found because my mysql connection was not established. :(




回答3:


In Application > Config > database.php set

db['default'] = array(
                 ..,
                'db_debug' => FALSE,
                 ..)


来源:https://stackoverflow.com/questions/12327775/database-connection-settings-with-db-debug-set-as-false

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!