+ -
当前位置:首页 → 问答吧 → 为什么错误不提示

为什么错误不提示

时间:2011-07-31

来源:互联网

$Form    = M("Pic_post");
    $condition['cid']    =    array('eq',$cid);
    $condition['status']    =    5;
    $list    =    $Form->where($condition)->limit($num)->order('id desc')->select();

我id是 pid

按理应该提示
#1054 - Unknown column 'id' in 'order clause'

可是为什么不提示!怎么开启提示呢?谢谢了

只是把sql打印出来!我要的是提示错误!不知道有没有这个功能

作者: cyr11   发布时间: 2011-07-31

没想到论坛这样冷静

作者: cyr11   发布时间: 2011-08-01

看了一下源码
dbmysql.class.php

加了一点代码
  1.         if ( false === $this->queryID ) {
  2.                  if ( $this->debug ) {
  3.                              return $this->error();
  4.                  }else{
  5.                          $this->error();
  6.                          return FALSE;
  7.                  }
  8.         }
复制代码
现在终于爽了!~
错误的sql打印出来!

作者: cyr11   发布时间: 2011-08-01

想来想去
这样更合适一点!先留个记号
  1. thinkphp/lib/think/db/driver/dbmysql.class.php

  2.     public function error() {
  3.             if ( false === $this->queryID ) {
  4.         $this->error = mysql_errno($this->_linkID)."\n注意看说明:\n".mysql_error($this->_linkID);
  5.         if($this->debug && '' != $this->queryStr){
  6.             $this->error .= "\n [ SQL语句 ] : \n";
  7.         }           
  8.         return $this->error;
  9.             }
  10.     }

  11. thinkphp/lib/think/db/db.class.php
  12.     protected function debug() {
  13.         // 记录操作结束时间
  14.         if ( $this->debug ) {
  15.             G('queryEndTime');
  16.             Log::record($this->error().$this->queryStr." [ RunTime:".G('queryStartTime','queryEndTime',6)."s ]",Log::SQL);
  17.         }
  18.     }
复制代码

作者: cyr11   发布时间: 2011-08-01

你开启调试模式 就会提示错误了

作者: thinkphp   发布时间: 2011-08-01