<?php
/*
* 项目: iOrange(橘子)
* 作者: 离家出走(yzxh24)
* Email: yzxh24@gmail.com
* 主页: www.iorange.cc
*/
/* vim: set ts=4 sw=4: */
class IndexAction extends ForumAction
{
    public function run()
    {
        $count = $this->db()->getValue('SELECT COUNT(*) FROM `'.BookBan::table().'` WHERE `bookid` = '.$this->id());
        $pageObj = new iPage();
        $pageObj->setPageSize(10);
        $pageObj->setTotalRecord($count);
        
        $sql = 'SELECT * FROM `'.BookBan::table().'` WHERE `bookid` = '.$this->id().' AND expiry > '.CTIME.' LIMIT '.$pageObj->getOffset().','.$pageObj->getPageSize();
        $members = $this->db()->setQueryString($sql)->find();
        
        $this->getController()->render('index', array(
                'bookid' => $this->id(),
                'members' => $members,
                'pageObj' => $pageObj,
                'floor' => $pageObj->getFloor(),
            )
        );
    }
}