官术网_书友最值得收藏!

Creating the database

Okay, you should have already set up CodeIgniter and Bootstrap as described in Chapter 1, Introduction and Shared Project Resources. If not, then you should know that the code in this chapter is specifically built with the setup from Chapter 1, Introduction and Shared Project Resources, in mind. However, it's not the end of the world—the code can easily be applied to other situations.

Firstly, we'll build the database. Copy out the following MySQL code into your database:

CREATE DATABASE `urls`;
USE `urls`;

CREATE TABLE `urls` (
  `url_id` int(11) NOT NULL AUTO_INCREMENT,
  `url_code` varchar(10) NOT NULL,
  `url_address` text NOT NULL,
  `url_created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`url_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

Tip

You don't have to call the database urls if you don't want to. Feel free to rename to something else if you wish; just be sure to update the config/database.php file accordingly.

Let's take a look at what each item in the database means:

We'll also need to make amends to the config/database.php file—namely setting the database access details, username password, and so on.

Open the config/database.php file and find the following lines:

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'your username';
$db['default']['password'] = 'your password';
$db['default']['database'] = 'urls';

Edit the values in the preceding lines. Ensure you substitute those values with the ones that are more specific to your setup and situation—so enter your username, password, and so on.

主站蜘蛛池模板: 宜川县| 迭部县| 灵宝市| 常德市| 莒南县| 二连浩特市| 赫章县| 新野县| 保亭| 邵阳市| 新疆| 隆林| 于都县| 枣强县| 蓝山县| 平塘县| 顺义区| 本溪市| 绥芬河市| 双流县| 思南县| 吉木萨尔县| 泗阳县| 洪湖市| 中方县| 眉山市| 曲阳县| 长葛市| 临朐县| 长沙市| 南澳县| 临颍县| 萝北县| 海伦市| 白沙| 蒙山县| 沈阳市| 昔阳县| 五家渠市| 平安县| 肇州县|