问题
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