So far, almost all of the files that generate front-end pages don't contain data access logic and are easier to manage. On the other hand, the model classes can be used from outside our application, and additional pages can be quickly created to represent the information in the database in other formats such as XML.
For example, consider the following page (which we will call books.xml.php):
<?php /** * This page lists all the books we have as an XML data structure * PDO Library Management example application * @author Dennis Popel */ // Don't forget the include include('common.inc.php'); // Set the content type to be XML header('Content-Type: application/xml'); // Get the books list $books = Model::getBooksWithAuthors(); // Echo XML declaration and open root element echo '<?xml version="1.0"?>', "\n"; echo "<books>\n"; // Now iterate over every book and display it while($b = $books->fetch()) { ?> <book id="<?=$b->id?>"...