== Детален приказ на книга == === Актери === * Најавен корисник === Чекор 1 === Корисникот ја избира книгата за која сака да види подетални информации [[Image(BT-DB-1.png)]] === Чекор 2 === Детален приказ на книгата [[Image(BT-DB-2.png)]] {{{#!sql $sql = "SELECT book.*, book_details.*, firstname, lastname, author_description, author_image FROM book INNER JOIN book_author ON book.bookid = book_author.bookid INNER JOIN author ON book_author.authorid = author.authorid INNER JOIN book_details ON book.bookid = book_details.bookid WHERE book.bookid = :bookid; "; $stmt = $conn->prepare($sql); $stmt->bindParam(':bookid', $param, PDO::PARAM_INT); $sql2 = "SELECT b.BookID, b.TotalCopies - COALESCE(COUNT(l.LoanID), 0) AS AvailableCopies FROM Book b LEFT JOIN Loan l ON l.BookCopyID IN (SELECT CopyID FROM Book_Copies WHERE BookID = b.BookID) AND l.Status IN ('On Time', 'Soon', 'Overdue') WHERE b.BookID = :bookid GROUP BY b.BookID, b.TotalCopies;"; }}} === Чекор 3 === Повеќе книги [[Image(BT-DB-3.png)]] {{{#!sql //Similar Books $stmt = $conn->prepare("SELECT book.bookid, coverimage, title, genre, firstname, lastname FROM book INNER JOIN book_author ON book.bookid = book_author.bookid INNER JOIN author ON book_author.authorid = author.authorid WHERE book.genre = :bookgenre AND book.bookid != :bookid LIMIT 5; "); $stmt->bindParam(':bookgenre', $book_genre, PDO::PARAM_STR); $stmt->bindParam(':bookid', $bookid, PDO::PARAM_INT); // Execute the query $stmt->execute(); $similar_books = []; while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $similar_books[] = $row; } //More Author $stmt = $conn->prepare("SELECT book.bookid, coverimage, title, genre, firstname, lastname FROM book INNER JOIN book_author ON book.bookid = book_author.bookid INNER JOIN author ON book_author.authorid = author.authorid WHERE book_author.authorid IN ( SELECT book_author.authorid FROM book_author WHERE book_author.bookid = :bookid ) AND book.bookid != :bookid LIMIT 5; "); $stmt->bindParam(':bookid', $bookid, PDO::PARAM_INT); // Execute the query $stmt->execute(); $author_books = []; while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $author_books[] = $row; } }}}