PHP Classes

File: examples/library/www/book_author_delete.php

Recommend this page to a friend!
  Classes of Victor Bolshov   Tiny PHP ORM Framework   examples/library/www/book_author_delete.php   Download  
File: examples/library/www/book_author_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: 8 years ago
Size: 695 bytes
 

Contents

Class file image Download
<?php

use \library\Registry,
    \
tinyorm\Select,
    \
library\scaffold\BookHasAuthor;

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

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

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

$bookHasAuthor = (new Select("book_has_author"))
    ->
where("book_id = ?", (int) $_GET["book_id"])
    ->
where("author_id = ?", (int) $_GET["author_id"])
    ->
setFetchClass(BookHasAuthor::class)
    ->
execute()
    ->
fetch();

if (!
$bookHasAuthor) {
    die(
"This author is not registered for this book");
}

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

header("Location: book_edit.php?id=" . (int) $_GET["book_id"]);