PHP Classes
elePHPant
Icontem

File: examples/library/www/book_edit.php

Recommend this page to a friend!
  Classes of Victor Bolshov  >  Tiny PHP ORM Framework  >  examples/library/www/book_edit.php  >  Download  
File: examples/library/www/book_edit.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Tiny PHP ORM Framework
Map objects to databases using composed queries
Author: By
Last change: Improving library example
Date: 2 years ago
Size: 994 bytes
 

Contents

Class file image Download
<?php

use \library\Registry,
    \
library\Book,
    \
tinyorm\Select;

include
__DIR__ . "/../bootstrap.php";

if (empty(
$_GET["id"])) {
    die(
"No book ID provided");
}

/** @var Book $book */
$book = Registry::persistenceDriver()->find((int) $_GET["id"], new Book());
if (!
$book) {
    die(
"Book ID #" . (int) $_GET["id"] . " not found");
}

echo \
library\View::render("header.php", [
   
"title" => "Tinyorm Library: Edit book",
   
"description" => \library\View::render("sidebar/book_edit.html"),
]);

$allAuthors = (new Select("author"))
    ->
orderBy("name")
    ->
execute()
    ->
fetchAll(\PDO::FETCH_KEY_PAIR);

$bookAuthors = $book->getAuthors()->execute()->fetchAll();
$bookEditions = $book->getEditions()->execute()->fetchAll();

echo \
library\View::render(
   
"book_edit.php",
    [
       
"book" => $book,
       
"allAuthors" => $allAuthors,
       
"bookAuthors" => $bookAuthors,
       
"bookEditions" => $bookEditions,
    ]
);

echo \
library\View::render("footer.php"); ?>