PHP Classes

File: examples/library/www/book_save.php

Recommend this page to a friend!
  Classes of Victor Bolshov   Tiny PHP ORM Framework   examples/library/www/book_save.php   Download  
File: examples/library/www/book_save.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: 513 bytes
 

Contents

Class file image Download
<?php

use \library\Registry,
    \
library\Book;

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

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

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

$book->title = trim($_POST["title"]);

if (!
$book->title) {
    die(
"No book title provided");
}

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

header("Location: book_edit.php?id={$book->id}");
exit;