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

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.

主站蜘蛛池模板: 巴马| 万山特区| 肥西县| 高邮市| 六枝特区| 弋阳县| 敖汉旗| 南岸区| 阿图什市| 民权县| 库尔勒市| 桐柏县| 渭源县| 原平市| 莱州市| 嘉鱼县| 大理市| 交口县| 平潭县| 龙口市| 仪陇县| 湾仔区| 抚远县| 安图县| 昆山市| 博野县| 丰镇市| 吐鲁番市| 长海县| 靖州| 陇南市| 贵德县| 林芝县| 广元市| 淮北市| 右玉县| 嵩明县| 徐汇区| 五家渠市| 济源市| 正定县|