zoukankan      html  css  js  c++  java
  • 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两个同样的对象出来。这样的报错。

    积累知识,分享知识,学习知识。
  • 相关阅读:
    E. Paired Payment 题解(多维最短路)
    九峰与子序列 题解(dp+hash)
    魏迟燕的自走棋 题解(并查集+思维)
    unix学习资料
    Tomcat > Cannot create a server using the selected type
    myeclipse使用hibernate正向工程和逆向工程
    jira的破解
    jsp:useBean用法
    java一个多线程的经典例子
    head first系列PDF资源
  • 原文地址:https://www.cnblogs.com/bin-pureLife/p/4519419.html
Copyright © 2011-2022 走看看