Authors managing page is very similar to books.php. SQL for authors table:
CREATE TABLE book ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, title VARCHAR(255) ) ENGINE INNODB;
Generate Author entity.
$ php ../../bin/generate.php --dbname=tinyorm_library --password=*** --table=author --class='library\scaffold\Author' --file=lib/scaffold/Author.php
Then, again, we create class library\Author which extends the scaffold one.
author_add.php is almost completely the same as book_add.php.
f example.To fetch all authors, we use the following code:
$books = (new Select("book")) ->orderBy("title") ->execute();
This is equivalent of "SELECT * FROM author ORDER BY title".
Now, it is time to link authors to books. In this application, this is done on book_edit.php page.
Our author list has "Delete" links in it. Those lead to author_delete.php:
if (empty($_GET["id"])) { die("No author ID provided"); } /** @var Author $author */ $author = Registry::persistenceDriver()->find((int) $_GET["id"], new Author()); if (!$author) { die("Author #" . (int) $_GET["id"] . " not found"); } Registry::persistenceDriver()->delete($author);