- CodeIgniter 1.7
- David Upton Jose Argudo Blanco
- 415字
- 2021-04-01 13:45:31
Configuration settings
As for the other configuration settings you have done for CodeIgniter, the file you need to modify is in /www/codeigniter/application/config
. This time, the file you need to update is database.php
. This file contains all the information necessary for CodeIgniter to connect to your database. Open the file, you will see the options that you must set along with a few other options that you can leave at the default, for now.
$active_group = "default"; $active_record = TRUE; $db['default']['hostname'] = "localhost"; $db['default']['username'] = ""; $db['default']['password'] = ""; $db['default']['database'] = ""; $db['default']['dbdriver'] = "mysql"; $db['default']['dbprefix'] = ""; $db['default']['pconnect'] = TRUE; $db['default']['db_debug'] = TRUE; $db['default']['cache_on'] = FALSE; $db['default']['cachedir'] = ""; $db['default']['char_set'] = "utf8"; $db['default']['dbcollat'] = "utf8_general_ci";
The options you must fill in are:
hostname
: The location of your database, for example,localhost
or an IP address.username
andpassword
: The username and password of a database user with sufficient permissions to do whatever you may want your site to do. This is not (usually) the same username and password as of your site or your ISP's control panel.database
: The name of your database, for example,websites
.dbdriver
: The type of database you're using. At the time of writing, the options CI offers are MySQL, MySQLi, Postgre SQL, ODBC, and MS SQL.
From experience, it can be said that one of the most difficult things to set up on a new CI site can be a link to the database. You may need to consult your ISP if in doubt—sometimes their database runs at a different address than their web server's. If you are using MySQL, they may offer phpMyAdmin, which usually tells you the hostname—this may be localhost
or it may be an IP address.
Note
If you are new to phpMyAdmin you can find all you need in this Packt book:
http://www.packtpub.com/ mastering-phpmyadmin-3-1-fourth-edition/book
It is strongly recommended!
You'll note that this part of the config
file is actually a multi-dimensional array. Within $db
is an array called default
, and you're adding key/variable pairs like hostname = 127.0.0.1
to that array. Because of this you can set up other databases, as secondary arrays. You can swap between them easily by simply changing the $active_group
setting to the name of another array.
This makes it possible to run a site with several database options—for instance, a test database and a production database—and to swap between them easily. Or you might need to draw information from two separate databases.
- After Effects CC影視后期制作實戰從入門到精通
- Illustrator CS6核心應用案例教程(全彩慕課版)
- Solid Works 2021產品設計標準教程
- Photoshop 平面廣告設計從入門到精通
- 中文版CorelDRAW X6基礎培訓教程
- 平面設計綜合教程:Photoshop+Illustrator+CorelDRAW +InDesign(微課版)
- 24小時全速學會Photoshop 2021
- After Effects影視特效立體化教程:After Effects 2021(微課版)
- PS App UI設計從零開始學
- 神奇的中文版Photoshop CC 2017入門書
- Photoshop CC 2017 淘寶美工設計實例教程
- Word-Excel-PowerPoint 2010三合一辦公應用實戰從入門到精通(超值版)
- 音樂制作7天速成:Cubase編曲教程
- Instant Flask Web Development
- Unreal Development Kit Beginner's Guide