thinkphp 吐槽篇 SQLSTATE[42S02]: Base table or view not found: 1146 La table 'yps.yps_' n'existe pas
这次项目还没开始,在坐准备工作的时候出了些让我意料之外的状况;
第一个: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 这是一句可执行代码
客户端报错:
虽然改过后对了;不报错了;
总之不明白为何要new两个同样的对象出来。这样的报错。