function handleGET($conn) { $books = Book::getAllBooks($conn); //var_dump($books);//* wyswietlenie w formacie tablicy assocjacyjnej $json = json_encode($books); //* wyswietlanie w fromacie Json echo $json; }
function handleGET() { $conn = Connection::startConnection(); $books = Book::getAllBooks($conn); header('Content-type: application/json'); $json = json_encode($books); echo $json; Connection::stopConnecion($conn); }
public function testGetAllBooks() { // All books by first letter $entryArray = Book::getAllBooks(); $this->assertCount(9, $entryArray); }
public function InitializeContent() { $this->title = localize("allbooks.title"); if (getCurrentOption("titles_split_first_letter") == 1) { $this->entryArray = Book::getAllBooks(); } else { list($this->entryArray, $this->totalNumber) = Book::getBooks($this->n); } $this->idPage = Book::ALL_BOOKS_ID; }
<?php require_once "./src/connection.php"; if ($_SERVER['REQUEST_METHOD'] === 'GET' && !isset($_GET['id'])) { $tab = []; $tab = Book::getAllBooks(); echo json_encode($tab); } if ($_SERVER['REQUEST_METHOD'] === 'GET' && isset($_GET['id'])) { $tab = Book::GetSingleBook($_GET['id']); echo json_encode($tab); } if ($_SERVER['REQUEST_METHOD'] === 'POST') { $newName = $_POST['title']; $newAuthor = $_POST['author']; $newDesc = $_POST['description']; Book::AddBook($newName, $newAuthor, $newDesc); echo json_encode([]); } if ($_SERVER['REQUEST_METHOD'] === 'DELETE') { $toDel = json_decode(file_get_contents('php://input')); Book::DeleteBook($toDel['id']); echo json_encode([]); }