鲢Thinkphp sqlѯ 鿴
ѡҪҵThinkphp\Core\Library\Think\Db\Driver.class.php רҵߴ
ҵ queryif($fetchSql){ǰһ if(isset($GLOBALS["echosql"])){ echo $this->queryStr;}ij public function query($str,$fetchSql=false) { $this->initConnect(false); if ( !$this->_linkID ) return false; $this->queryStr = $str; if(!empty($this->bind)){ $that = $this; $this->queryStr = strtr($this->queryStr,array_map(function($val) use($that){ return '\''.$that->escapeString($val).'\''; },$this->bind)); }if(isset($GLOBALS["echosql"])){unset($GLOBALS["echosql"]); echo $this->queryStr;} if($fetchSql){ return $this->queryStr; } Ҫsqlڿ д$GLOBALS["echosql"]=1;//Ƕ$user=M("user");$result = $user->where($where)->find(); exit();ͿԿʾģthinkphpĴʾ