Esempio n. 1
0
 public function getUsedCount()
 {
     $table = new Book_Model_DbTable_Books();
     $tblName = $table->info('name');
     $select = $table->select()->from($tblName, "COUNT(*) as count")->where("{$tblName}.category_id = ?", $this->getIdentity());
     $total = $table->fetchRow($select);
     return $total['count'];
 }
Esempio n. 2
0
 public function getBookFromBookLinkId($bookLinkId)
 {
     $bookTbl = new Book_Model_DbTable_Books();
     $bookTblName = $bookTbl->info(Zend_Db_Table_Abstract::NAME);
     $rawBookTblName = $this->info(Zend_Db_Table_Abstract::NAME);
     $bookSelect = $bookTbl->select()->setIntegrityCheck(false);
     $bookSelect->join($rawBookTblName, "{$bookTblName}.rawbook_id = {$rawBookTblName}.rawbook_id");
     $bookSelect->where("{$rawBookTblName}.link_id=?", $bookLinkId);
     return $bookTbl->fetchRow($bookSelect);
 }
Esempio n. 3
0
 public function indexAction()
 {
     $post = Engine_Api::_()->core()->getSubject();
     if (!empty($post->parent_object_type) && !empty($post->parent_object_id)) {
         if ($post->parent_object_type == 'book') {
             $bookTbl = new Book_Model_DbTable_Books();
             $bookSelect = $bookTbl->getSelect()->where('book_id = ?', $post->parent_object_id);
             $this->view->book = $book = $bookTbl->fetchRow($bookSelect);
             $this->view->authors = $authors = $book->getAuthors(0);
             $categoryTable = new Book_Model_DbTable_Categories();
             $this->view->category = $categoryTable->findRow($book->category_id);
             $bookApi = Engine_Api::_()->book();
             $this->view->viewer = $viewer = Engine_Api::_()->user()->getViewer();
             $this->view->rated = $bookApi->checkRated($book->getIdentity(), $book->getType(), $viewer->getIdentity());
             if ($book->is_foreign) {
                 $this->view->translators = $translators = $book->getAuthors(1);
             }
         }
     } else {
         return $this->setNoRender();
     }
 }
Esempio n. 4
0
 private function _getBook()
 {
     $bookId = $this->_getParam('id');
     if ($bookId) {
         $bookTbl = new Book_Model_DbTable_Books();
         $book = $bookTbl->fetchRow($bookTbl->select()->where('book_id = ?', $bookId));
         return $book;
     }
 }