PHP Classes

File: examples/library/www/book_delete.php

Recommend this page to a friend!
  Packages of Victor Bolshov   Tiny PHP ORM Framework   examples/library/www/book_delete.php   Download  
File: examples/library/www/book_delete.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:
Date: 10 years ago
Size: 576 bytes
 

 

Contents

Class file image Download
<?php

use \library\Registry,
    \library\Book;

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 #" . (int) $_GET["id"] . " not found");
}

$editionCount = $book->getEditions()->count();
if ($book->getEditions()->count()) {
    die("Cannot delete this book because it still has $editionCount edition(s) listed!");
}

Registry::persistenceDriver()->delete($book);

header("Location: books.php");