function AddBookShelf($id_book, $id_shelf) { $id_book = max(0, (int) $id_book); $id_shelf = max(0, (int) $id_shelf); $time = time(); $query = 'INSERT INTO `users_bookshelf` SET `id_user`=' . $this->id . ',`id_book`=' . $id_book . ', `bookshelf_type`=' . $id_shelf . ', `add_time`=' . $time . ' ON DUPLICATE KEY UPDATE `id_book`=' . $id_book . ', `bookshelf_type`=' . $id_shelf . ', `add_time`=' . $time . ''; Database::query($query); $this->shelf[$id_shelf][$id_book] = array('id_user' => $this->id, 'id_book' => $id_book, 'bookshelf_type' => $id_shelf, 'add_time' => $time); $event = new Event(); $event->event_addShelf($this->id, $id_book, $id_shelf); $event->push(); }