標籤: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>