Debug info on query

Please report bugs here, please be very detailed in your bug reports. If you've come up with some code to fix the bug, please post it here.
Post Reply
Simon Illian
Greenhorn
Posts: 15
Joined: Sat Jun 14, 2008 20:24

Debug info on query

Post by Simon Illian » Tue Nov 07, 2006 16:33

Hello I've replace the execute function in the db.php file and added anotehr function :

Code: Select all

	function _color_sql($requete)
		{
		$requete=strtolower($requete);
		$motclef=array('from','where','and','order by','values','group by','inner join');
		$premier=array('select','update','insert','delete');
		$blue=array('"',"'",',','(',')',' on ',' as ');
		if(strstr(strtoupper($requete),'UPDATE')) /* Rajout du mot clef , en cas d'update pour la lisibilité*/
			$motclef[]=',';
		$requete='<font color=#003300>'.$requete.'</font>';
		foreach($motclef as $mot)
			$requete=eregi_replace($mot,"<font color=#FF0000><br>".strtoupper($mot)."</font>",$requete);	
		foreach($premier as $mot)
			$requete=eregi_replace($mot,"<font color=#FF0000>".strtoupper($mot)."</font>",$requete);	
		foreach($blue as $mot)
			$requete=str_replace($mot,"<font color=blue>".strtoupper($mot)."</font>",$requete);	

	return $requete;
	}
    function execute( $sql )
    {
      $t1 = strtok(microtime(), ' ') + strtok('');

      $this->resid_ = mysql_query( $sql, $this->dbconn_->id() );

      if ( !$this->resid_ ) {
		$traceArr = debug_backtrace();
        echo "<b>Database error: </b>".mysql_error( $this->dbconn_->id() )."<br>";
        echo "<p>".$this->_color_sql($sql)."</p><br>";

	echo '<b>Line :</b> ' .$traceArr[0]['line'].'<br>';//(isset($traceArr[$niveau]['line'])? $traceArr[$niveau]['line'] : "unknown").'<br>';
	echo '<b>File : </b>' .$traceArr[0]['file'];//(isset($traceArr[$niveau]['file'])? $traceArr[$niveau]['file'] : "unknown");
	exit;
      }
      
      $this->exectime_ = strtok(microtime(), ' ') + strtok('') - $t1;
      $this->executed_ = true;

      if ( KB_PROFILE == 2 ) {
	file_put_contents ( '/tmp/profile.lst', $sql."\nExecution time: ".$this->exectime_."\n", FILE_APPEND );
      }
        
      return true;
    }

Post Reply

Return to “Bug Reporting”

Who is online

Users browsing this forum: No registered users and 9 guests