时间:2021-07-01 10:21:17 帮助过:22人阅读
html
public function index() { try{ $pagesize = 10; $Teacher = new Teacher; //$Teachers = $Teacher->select(); $Teachers = $Teacher->paginate($pagesize); // $teacher = $Teachers[0]; //var_dump($teacher->getData()); //echo ‘<br />‘; //echo $teacher->getData(‘name‘); //echo ‘<br />‘; //return $teacher->getData(‘name‘); $this->assign(‘Teachers‘,$Teachers);//像视图传递数据 //取回打包后的数据 $htmls = $this->fetch(); //将数据返回给用户 return $htmls; }catch(\think\Exception\httpResponseException $e){ throw $e; }catch(\Exception $e){ return $e->getMessage(); } }
PHP
最开始是上面那样的方法
解决方案:
<div class="col-md-12"> <hr /> <a href="{:url(‘add‘)}" class="btn btn-primary"><i class="glyphicon glyphicon-plus"></i> 增加</a> <hr /> <table class="table table-hover table-bordered"> <tr class="info"> <th>序号</th> <th>姓名</th> <th>性别</th> <th>邮箱</th> <th>用户名</th> <th>操作</th> </tr> {volist name="Teachers" id="Teachers" key="key"} <tr> <td>{$key}</td> <td>{$Teachers->getData(‘name‘)}</td> <td>{eq name=‘$Teachers->getData("sex")‘ value=‘0‘}男{else /}女{/eq}</td> <td>{$Teachers->getData(‘email‘)}</td> <td>{$Teachers->getData(‘username‘)}</td> <td><a href="{:url(‘edit?id=‘.$Teachers->getData(‘id‘))}">编辑 </a> <a href="{:url(‘delete?id=‘.$Teachers->getData(‘id‘))}">删除</a></td> </tr> {/volist} </table> 当前页总条数{$Teachers->count()} {$page} </div>
PHP
public function index() { try{ $pagesize = 10; $Teacher = new Teacher; //$Teachers = $Teacher->select(); $Teachers = $Teacher->paginate($pagesize); $page = $Teachers->render();
//调用render()方法 新添加的这里 // $teacher = $Teachers[0]; //var_dump($teacher->getData()); //echo ‘<br />‘; //echo $teacher->getData(‘name‘); //echo ‘<br />‘; //return $teacher->getData(‘name‘); $this->assign(‘Teachers‘,$Teachers);//像视图传递数据 $this->assign(‘page‘,$page);//这里要重新传递一下 $htmls = $this->fetch(); //将数据返回给用户 return $htmls; }catch(\think\Exception\httpResponseException $e){ throw $e; }catch(\Exception $e){ return $e->getMessage(); } }//千锋PHP-PHP培训的实力派
关于method not exist:think\db\Query->render错误解决方法
标签:email inf phi ble border delete data 视图 log