首页 > 代码库 > 关于method not exist:think\db\Query->render错误解决方法
关于method not exist:think\db\Query->render错误解决方法
{volist name="Teachers" id="Teachers" key="key"} <tr> <td>{$key}</td> <td>{$Teachers->getData(‘name‘)}</td> <td>{eq name=‘$Teachers->getData("sex")‘ value=http://www.mamicode.com/‘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()} {$Teachers->render()} </div>
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=http://www.mamicode.com/‘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错误解决方法
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。