$bdi->saveBook($book); $array['DT_RowId'] = $book->getId(); $array['Book Title'] = $book->getTitle(); $array['Book Year'] = $book->getYear()->format('d-m-Y'); $array['Book Img'] = $book->getImg(); $array['About'] = $book->getRecap(); $array['Book Price'] = $book->getPrice(); echo json_encode(array('row' => $array)); } else { if (strcmp(trim($_POST['action']), 'remove') == 0) { $ids = $_POST['id']; $book = $bdi->getBookById($ids[0]); if ($book != null) { $bdi->removeBook($book); } foreach ($bdi->getAllBooks() as $book) { $array['DT_RowId'] = $book->getId(); $array['Book Title'] = $book->getTitle(); $array['Book Year'] = $book->getYear()->format('d-m-Y'); $array['Book Img'] = $book->getImg(); $array['About'] = $book->getRecap(); $array['Book Price'] = $book->getPrice(); $final[] = $array; } echo json_encode(array('data' => $final)); } } } } else { $array = array(); $final = array();
$a = round($size / 6); $b = $size % 6; if ($b == 0) { return 6; } else { if ($page == $a + 1) { return $b; } else { return 6; } } } } if (isset($_POST['action'])) { $bdi = new BookDaoImp($entityManager); $books = $bdi->getAllBooks(); $collections = new ArrayCollection($books); if (isset($_POST['sort'])) { if (strcmp($_POST['sort'], 'high') == 0) { $criteria = Criteria::create()->orderBy(array("price" => Criteria::DESC)); } else { if (strcmp($_POST['sort'], 'low') == 0) { $criteria = Criteria::create()->orderBy(array("price" => Criteria::ASC)); } } } else { $criteria = Criteria::create()->orderBy(array("price" => Criteria::ASC)); } $sortedBooks = $collections->matching($criteria); if (isset($_POST['page']) && strcmp($_POST['action'], 'square') == 0) { if (sizeof($books) > 0) {