Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $this->db->beginTransaction();
- try
- {
- $this->db->query("SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED");
- $sth = $this->db->prepare("INSERT INTO books(title, categoryID, publisherID, date, description, price, image)
- VALUES (:title, :categoryID, :publisherID, :date, :description, :price, :image)");
- $sth->execute(array(
- ':title' => $title,
- ':categoryID' => $categoryID,
- ':publisherID' => $publisherID,
- ':date' => $date,
- ':description' => $description,
- ':price' => $price,
- ':image' => $image_path
- ));
- $bookID = $this->db->prepare("SELECT bookID FROM books WHERE title = :title");
- $bookID->execute(array(
- ':title' => $title,
- ));
- $row=$bookID->fetch();
- $book = intval($row[0]);
- $sth = $this->db->prepare("INSERT INTO books_authors(bookID,authorID)
- VALUES (:bookID, :authorID)");
- $sth->execute(array(
- ':bookID' => $book,
- ':authorID' => $authorID
- ));
- $this->db->commit();
- }
- catch (PDOException $e)
- {
- $this->db->rollback();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement