如果您轉到application
文件夾codeigniter
,將會出現一個config
文件夾,其中包含一個名爲database.php
的文件。該文件包含應用程序的數據庫連接。
事情是這樣的:
/*
| -------------------------------------------------------------------
| DATABASE CONNECTIVITY SETTINGS
| -------------------------------------------------------------------
| This file will contain the settings needed to access your database.
|
| For complete instructions please consult the 'Database Connection'
| page of the User Guide.
|
| -------------------------------------------------------------------
| EXPLANATION OF VARIABLES
| -------------------------------------------------------------------
|
| ['hostname'] The hostname of your database server.
| ['username'] The username used to connect to the database
| ['password'] The password used to connect to the database
| ['database'] The name of the database you want to connect to
| ['dbdriver'] The database type. ie: mysql. Currently supported:
mysql, mysqli, postgre, odbc, mssql, sqlite, oci8
| ['dbprefix'] You can add an optional prefix, which will be added
| to the table name when using the Active Record class
| ['pconnect'] TRUE/FALSE - Whether to use a persistent connection
| ['db_debug'] TRUE/FALSE - Whether database errors should be displayed.
IF您使用的應用程序中的數據庫,請確保該文件中的連接設置是否正確。
如果您在應用程序中未使用數據庫,則可能是數據庫連接正在自動加載,這會導致應用程序失敗。在這種情況下,去autoload.php
文件,該文件是在同一個文件夾,檢查以下行:
/*
| -------------------------------------------------------------------
| Auto-load Libraries
| -------------------------------------------------------------------
| These are the classes located in the system/libraries folder
| or in your application/libraries folder.
|
| Prototype:
|
| $autoload['libraries'] = array('database', 'session', 'xmlrpc');
*/
$autoload['libraries'] = array('database');
如果database
被自動加載,從數組中刪除它,你的應用程序應該只是罰款。
謝謝,我會盡力,謝謝。 – ag0702
非常感謝你解決了我的問題,我正在檢查代碼,所以數據庫用戶名等不同,再次感謝你。 – ag0702