O'Reilly logo

Professional CodeIgniter® by Thomas Myer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

3.6. Creating Models, Views, and Controllers

At this point, you're ready to start working with files that relate directly to your project — namely, the models, views, and controllers that make up the heart of the application you'll be building for Claudia.

3.6.1. Models and Database Tables

You received an extremely brief introduction to models, views, and controllers in Chapter 1, so in this section, you'll concentrate on the database tables and models you'll need for Claudia's project. Before you delve too deeply into constructing models for your tables, here's a quick reminder of the tables' structures from Chapter 2:

First, the categories table:

CREATE TABLE 'categories' (
'id' INT NOT NULL AUTO_INCREMENT,
'name' VARCHAR( 255 ) NOT NULL,
'shortdesc' VARCHAR( 255 ) NOT NULL,
'longdesc' TEXT NOT NULL,
'status' ENUM( 'active', 'inactive' ) NOT NULL,
'parentid' INT NOT NULL,
PRIMARY KEY ( 'id' )
) TYPE = MYISAM;

Next, the products table:

CREATE TABLE 'products' (
'id' INT NOT NULL AUTO_INCREMENT,
'name' VARCHAR( 255 ) NOT NULL,
'shortdesc' VARCHAR( 255 ) NOT NULL,
'longdesc' TEXT NOT NULL,
'thumbnail' VARCHAR( 255 ) NOT NULL,
'image' VARCHAR( 255 ) NOT NULL,
'sizes' ENUM( 's', 'm', 'l', 'xl' ) NOT NULL,
'colors' ENUM( 'red', 'blue', 'green', 'brown', 'white', 'black' ) NOT NULL,
'grouping' VARCHAR( 16 ) NOT NULL,
'status' ENUM( 'active', 'inactive' ) NOT NULL,
'category_id' INT NOT NULL,
'featured' ENUM ('true', 'false') NOT NULL, 'price' FLOAT( 4, 2 ) NOT NULL, PRIMARY KEY ( ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required