公益圖書館-UserController-代碼學習

來源:互聯網
上載者:User

標籤:des   style   blog   color   使用   io   資料   cti   

1、我的捐書資訊

/**     * @author Edwin     * @description 顯示捐書資訊     */    public function donate()    {        $BookDB = D(‘Book‘); //擷取BOOK資料表對象,執行個體化        $id = session(‘user‘)[‘id‘]; //擷取目前使用者id資訊,比如我的id是73        $where[‘contributor_id‘] = $id; //contributor_id = $id為查詢條件        $count = $BookDB->where($where)->count(); //查詢Book資料庫id為73的記錄,即目前使用者記錄        $pager = new Pager($count, "/user/donate", 5); //使用分頁欄類來分頁顯示目前使用者已捐書籍$count表示總的記錄數,"/user/donate"為當前網址(控制器及方法),5為每頁顯示記錄數為5        $limit = $pager->firstItem . ‘,‘ . $pager->pageSize; //讀取當前頁對應的(1,5)第1到第5條(或第6到第10條(6,5))條記錄        $list = $BookDB->where($where)->limit($limit)->select();//把讀取出來的目前使用者捐贈資訊放入$list中        $this->info_donate=$list; //把讀取出來的記錄傳遞給視圖頁面的info_donate變數        $this->pager = $pager; //??        $this->display();    }

2、我的個人資訊

<extend name="Template:template"/><block name="title">    <title>我的個人資訊</title></block><block name="content">    <table class="table table-striped">        <caption>我的個人資訊</caption>        <thead>        <tr>            <th>使用者名稱</th>            <th>上次登陸時間</th>            <th>上次登入ip</th>            <th>email</th>        </tr>        </thead>        <volist name="info_user" id="vo">            <tbody>            <tr>                <td>{$vo.username}</td>                <td>{$vo.last_login_time|date=‘y-m-d H:i‘,###}</td> //注意時間戳記的轉換格式                <td>{$vo.last_login_ip}</td>                <td>{$vo.email}</td>            </tr>            </tbody>        </volist>    </table>    </table></block></extend>

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.