• thinkphp 吐槽篇


    这次项目还没开始,在坐准备工作的时候出了些让我意料之外的状况;

    第一个:THINKPHP 保留字 

        具体表现在表单提交,不管是get 还是post  如果有某某 name = "a" 提交过去会报非法错误,错误码为你name="a" 的value值  

    第二个 连表查询的时候;

             代码如下:

             

     改良后:
     $modelsel = D();
                $modelcou = D();
                $count = $modelcou->Table($table)->where($where);
                //无奈 又要根据group  order 进行判断 由于多表 无法默认order by  和group by  除非配置默认  但是并不是所有都需要group by
                $list  = $modelsel->Table($table)
                    ->where($where)
                    ->field($field);
                if($order && $group){
                    $list = $list->group($group)
                                 ->order($order);
                    //$count = $count->group($group);
                }else if($group){
                    $list = $list->group($group);
                    //$count = $count->group($group);
                }else if($order){
                    $list = $list->order($order);
                }
    
                $count = $count->count();
    
                $Page  = new Page($count,$limit);
                $show  = $Page->show();
                $list = $list->limit($Page->firstRow.','.$Page->listRows)
                             ->select();
    未改良:
     $modelsel = D();
                $modelcou = D();
                $count = $modelcou->Table($table)->where($where);
                //无奈 又要根据group  order 进行判断 由于多表 无法默认order by  和group by  除非配置默认  但是并不是所有都需要group by
                $list  = $modelsel->Table($table)
                    ->where($where)
                    ->field($field);
                if($order && $group){
                    $list = $list->group($group)
                                 ->order($order);
                    //$count = $count->group($group);
                }else if($group){
                    $list = $list->group($group);
                    //$count = $count->group($group);
                }else if($order){
                    $list = $list->order($order);
                }
    
                $count = $count->count();
    
                $Page  = new Page($count,$limit);
                $show  = $Page->show();
                $list = $list->limit($Page->firstRow.','.$Page->listRows)
                             ->select();

    区别不大:改过后new了两次D()

    未改良时候

    sql记录:SELECT COUNT(*) AS tp_count FROM `yps_test` `test` GROUP BY test.`b`LIMIT 1 这是一句可执行代码

    客户端报错:

    SQLSTATE[42S02]: Base table or view not found: 1146 La table 'yps.yps_' n'existe pas

    虽然改过后对了;不报错了;

    总之不明白为何要new两个同样的对象出来。这样的报错。

    积累知识,分享知识,学习知识。
  • 相关阅读:
    Sublime Text 3 3126 注册码
    修改bootstrap 的全局样式,bootstrap 3.0 是由html5和CSS 3组成的
    mysql-sql高级应用
    MySQL 主键冲突,无法插入数据
    jquery加载页面的方法(页面加载完成就执行)
    Jquery怎么获取select选中项 自定义属性的值
    使用Yii2中dropdownlist实现地区三级联动的例子
    Yii2中省市三级联动(栏目联动)
    [HNOI2009] 梦幻布丁
    [CJOJ2410]数列操作d
  • 原文地址:https://www.cnblogs.com/bin-pureLife/p/4519419.html
Copyright © 2020-2023  润新知