We need to first create two tables??”one for recipes and the other for
comments. The following code shows the SQL to create these tables.
CREATE TABLE `recipes` (
`id` int(10) unsigned NOT NULL auto_increment,
`submitter` varchar(75) NOT NULL,
`submitterPhone` varchar(20) NOT NULL,
`photo` varchar(30) NOT NULL,
`dateUpdated` timestamp NOT NULL,
`title` varchar(30) NOT NULL,
`basicInfo` mediumtext NOT NULL,
`ingredients` mediumtext NOT NULL,
`directions` mediumtext NOT NULL,
PRIMARY KEY (`id`)
) COMMENT='Hot recipes';
CREATE TABLE `recipeComments` (
`id` int(10) unsigned NOT NULL auto_increment,
`recipeId` int(11) unsigned NOT NULL,
`submitter` varchar(75) NOT NULL,
`submitterPhone` varchar(20) NOT NULL,
`dateUpdated` timestamp NOT NULL,
`comment` mediumtext NOT NULL,
PRIMARY KEY (`id`)
) COMMENT='Comments on recipes';
2. We can now add a few recipes and comments via phpMyAdmin, so that
when we do the rest of the code, we have some data to display. While
adding data, please ensure that you use proper recipeId values in the
recipeComments table.
3. Let us create the Recipe class now. It will extend the BaseModel class we have
been using in the rest of the POTR code, and will make it easy to retrieve or
save data from the recipe table.
Pages:
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250