phpcms v9의 debug 함수
                                            
 2236 단어  phpcms
                    
function usedtime(){
	$stime = explode(' ', SYS_START_TIME);
	$etime = explode(' ', microtime());
	return number_format(($etime[1] + $etime[0] - $stime[1] - $stime[0]), 6);
}
function debug(){
		if(!pc_base::load_config('system','debug') || defined('HTML')) return false;
	$myip = array(' debug ip ');
	pc_base::load_sys_class('db_factory', '', 0);
	$sql_status = db_factory::get_instance();
	$mysqlserver = pc_base::load_config('database');// sql
	$count = $querystr = array();
      foreach($mysqlserver AS $k=>$v){
	  $db_list = $sql_status->get_database($k);
	  $count[] = $k.':'. $db_list->querycount;
	  $querystr[] = $k.':'. implode(';<br />',$db_list->querystr);
	  }
	  $count = implode(';',$count);
      $querystr = implode(';',$querystr);
	  $output = '<table><tr><td> </td><td>'.usedtime().'</td></tr><tr><td>sql </td><td>'.$count.'</td></tr><tr><td>sql </td><td>'.$querystr.'</td></tr></table>';
	return in_array(ip(),$myip) ? $output : '';
}만약 다중 데이터베이스 서버를 사용한다면, 모든 서버의 조회 횟수를 통계할 수 있다.
또한 실행된 sql를 모두 출력하려면 mysql를 추가로 수정해야 합니다.class.php
변수 정의public $querystr =array () 추가;
다음 방법을 수정합니다.
	private function execute($sql) {
		if(!is_resource($this->link)) {
			$this->connect();
		}
		$stime = explode(' ', microtime());
		$this->lastqueryid = mysql_query($sql, $this->link) or $this->halt(mysql_error(), $sql);
		$etime = explode(' ', microtime());
		$sec_time = number_format(($etime[1] + $etime[0] - $stime[1] - $stime[0]), 6);
        if(pc_base::load_config('system','debug')) $this->querystr[] = $sql.'('.$sec_time.')';
		$this->querycount++;
		return $this->lastqueryid;
	}이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
PHPCMS_흔 한 질문 (1){get_memberavatar($r['userid'],1,45)} userid 로 호출 할 수 있다 면 이 코드 는 어디서 든 사용 할 수 있 습 니 다. 여기 서 나 는 get 으로 member 표 안의 use...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.