Helper\PageData::execute PHP Method

execute() public method

public execute ( )
    public function execute()
    {
        $this->countQuery->execute();
        $totalRecord = $this->countQuery->fetchColumn();
        $totalPage = max(ceil($totalRecord / $this->recordPrePage), 1);
        $this->currentPage = min($this->currentPage, $totalPage);
        $this->query->bindValue(':pageDataStart', ($this->currentPage - 1) * $this->recordPrePage, Database::PARAM_INT);
        $this->query->bindValue(':pageDataRPP', $this->recordPrePage, Database::PARAM_INT);
        $this->query->execute();
        $data = $this->query->fetchAll(Database::FETCH_ASSOC);
        return $this->context = array('data' => $data, 'totalPage' => $totalPage, 'currentPage' => $this->currentPage, 'pageSize' => $this->recordPrePage);
    }

Usage Example

Example #1
0
 /**
  * @JSON
  * @Authorization
  */
 public function getList()
 {
     $port = $_GET['port'];
     $email = $_GET['email'];
     $where = ' WHERE 1=1 ';
     if ($port) {
         $where .= " AND port={$port} ";
     }
     if ($email) {
         $where .= " AND email like '%{$email}%' ";
     }
     $pageData = new PageData('member', " {$where} ORDER BY uid", ['uid', 'port', 'email', 'nickname', 'plan', 'flow_up', 'flow_down', 'transfer', 'expireTime']);
     $pageData->execute();
     Template::setContext($pageData->getContext());
 }