zoukankan      html  css  js  c++  java
  • 关于method not exist:thinkdbQuery->render错误解决方法

     {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'))}">编辑&nbsp;&nbsp;</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(	hinkExceptionhttpResponseException $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>&nbsp;增加</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'))}">编辑&nbsp;&nbsp;</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( hinkExceptionhttpResponseException $e){ throw $e; }catch(Exception $e){ return $e->getMessage(); } }//千锋PHP-PHP培训的实力派
  • 相关阅读:
    [转载] VsCode中使用Emmet神器快速编写HTML代码
    Hexo 博客部署到私有云服务器
    钉钉小程序通过 Canvas 将页面生成图片并保存到本地相册
    2021你应该了解的前端知识体系
    JavaScript 中的模块化
    vue中click事件方法不加括号则会将事件作为入参
    css:左右元素没对齐,调整子元素的vertical-align属性
    js通过宽高特征对图片进行分类
    配置服务器上的git仓库
    js获取当前设备信息
  • 原文地址:https://www.cnblogs.com/gaohj/p/6942282.html
Copyright © 2011-2022 走看看