We can now go ahead and create our initial model classes Reviews and Places. These will be created in the
application/models directory and initially are very simple:
class Reviews extends Zend_Db_Table
{
}
class Places extends Zend_Db_Table
{
}
As we have already discussed in Chapter 2, Zend_Db_Table gives us all the functionality of a Table
Gateway without us having to write any code. As we have no intention of writing code that isn??™t going to be
used, we will not expand our model classes until we need to. For now, we??™ll just populate the database directly
with a few rows so we have something to display on the home page as shown in listing 3.5.
Listing 3.5 MySQL statements to create populate the tables with initial data
CREATE TABLE `places` (
`id` int(11) NOT NULL auto_increment, #1
`date_created` datetime NOT NULL, |#2
`date_updated` datetime NOT NULL, |#2
`name` varchar(100) NOT NULL,
`address1` varchar(100) default NULL,
`address2` varchar(100) default NULL,
`address3` varchar(100) default NULL,
`town` varchar(75) default NULL,
`county` varchar(75) default NULL,
`postcode` varchar(30) default NULL,
`country` varchar(75) default NULL,
PRIMARY KEY (`id`)
);
INSERT INTO places (name, address1, town, county, postcode, date_created)
VALUES
('London Zoo', 'Regent\'s Park', 'London', '', 'NW1 4RY', '2007-02-14 00:00:00')
,('Alton Towers', 'Regent\'s Park', 'Alton', 'Staffordshire', 'ST10 4DB', '2007-02-14 00:00:00')
,('Coughton Court', '', 'Alcester', 'Warwickshire', 'B49 5JA', '2007-02-14 00:00:00');
Licensed to Menshu You
Pages:
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106