The following code shows this class.
class Recipe extends BaseModel
{
public $_submitter;
public $_submitterPhone;
Chapter 10
[ 185 ]
public $_photo;
public $_dateUpdated;
public $_basicInfo;
public $_ingredients;
public $_directions;
public function __construct($tableName = "recipes",
$data = null)
{
parent::__construct($tableName, $data);
}
}
?>
4. Similarly, we can create the RecipeComment class. Let's add a function to get
all comments for a particular recipe too.
class RecipeComment extends BaseModel
{
public $_recipeId;
public $_dateUpdated;
public $_submitter;
public $_submitterPhone;
public $_comment;
public function __construct($tableName = "recipeComments",
$data = null)
{
parent::__construct($tableName, $data);
}
public function GetCommentsForRecipe($recipeId)
{
return $this->GetAll("recipeId = '$recipeId'",
"dateUpdated desc");
}
}
?>
5. It's time to create a PHP file that will show the recipes to the visitor. This
file will also make the AJAX calls and provide a form to comment on a
recipe. First, let's get the structure ready. Refer to the following code for
recipes.inc.
Pages:
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251