The model developed in this chapter, needs some improvements in at least two areas, if you want to use it in a real-life application. We didn't create methods in the model that would provide the functionality of the editBook.php
and editAuthor.php
files. However, you should now be ready to add this functionality by yourself. We will provide you with some tips:
Create the
Book::update()
andAuthor::update()
methods. These methods should accept parameters that reflect the properties of each object (for theAuthor
class, this should be first name, last name, and biography).These methods should use prepared statements to update the corresponding records in the database (based on the
$this->id
value).The
Model
class should be extended with two more methods,Model::createBook()
andModel::createAuthor()
. These methods should accept the same list of parameters asBook::update()
andAuthor::update()
. Both should insert a row based on the passed parameters, into the relevant table...