Some function is created to make code easy to read and manageable. The Lookup function is so powerfull to simplified data storage. Usually we store Approve, Not Approved, Qualified, Not Qualified in words for each records, but with Lookup class, we can make it short to an integer for each properties.
Table scheme “tbl_lookup”
[php]
CREATE TABLE tbl_lookup
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(128) NOT NULL,
code INTEGER NOT NULL,
type VARCHAR(128) NOT NULL,
position INTEGER NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
[/php]
Insert some records like this
[php]
INSERT INTO tbl_lookup (name, type, code, position) VALUES (‘Activated’, ‘ActivationStatus’, 1, 1);
INSERT INTO tbl_lookup (name, type, code, position) VALUES (‘Not Activated’, ‘ActivationStatus’, 2, 2);
INSERT INTO tbl_lookup (name, type, code, position) VALUES (‘Pending Approval’, ‘membership_status’, 1, 1);
INSERT INTO tbl_lookup (name, type, code, position) VALUES (‘Approved’, ‘membership_status’, 2, 2);
INSERT INTO tbl_lookup (name, type, code, position) VALUES (‘Not Approved’, ‘membership_status’, 3, 3);
[/php]