english/libraries/joomla/database/database/mysqli.php
/**
	 * Diagnostic method to return explain information for a query.
	 *
	 * @return      string  The explain output.
	 *
	 * @deprecated  11.2
	 * @since       11.1
	 */
Diagnostic method to return explain information for a query.
@return      string  The explain output.


Diagnostic method to return explain information for a query . @return string The explain output .
public function explain()
	{
		JLog::add('JDatabase::explain() is deprecated.', JLog::WARNING, 'deprecated');
		$backup = $this->sql;
		$this->sql = 'EXPLAIN '.$this->sql;
		if (!($cursor = $this->query())) {
			return null;
		}
		$first = true;
		$buffer = '<table id="explain-sql">';
		$buffer .= '<thead><tr><td colspan="99">'.$this->getQuery().'</td></tr>';
		while ($row = $this->fetchAssoc($cursor))
		{
			if ($first) {
				$buffer .= '<tr>';
				foreach ($row as $k=>$v)
				{
					$buffer .= '<th>'.$k.'</th>';
				}
				$buffer .= '</tr></thead><tbody>';
				$first = false;
			}
			$buffer .= '<tr>';
			foreach ($row as $k=>$v)
			{
				$buffer .= '<td>'.$v.'</td>';
			}
			$buffer .= '</tr>';
		}
		$buffer .= '</tbody></table>';
		$this->sql = $backup;
		$this->freeResult($cursor);
		return $buffer;
	}
public function explain ( ) { JLog :: add ( 'JDatabase::explain() is deprecated.' , JLog :: WARNING , 'deprecated' ) ; $ backup = $ this -> sql ; $ this -> sql = 'EXPLAIN ' . $ this -> sql ; if ( ! ( $ cursor = $ this -> query ( ) ) ) { return null ; } $ first = true ; $ buffer = '<table id="explain-sql">' ; $ buffer .= '<thead><tr><td colspan="99">' . $ this -> getQuery ( ) . '</td></tr>' ; while ( $ row = $ this -> fetchAssoc ( $ cursor ) ) { if ( $ first ) { $ buffer .= '<tr>' ; foreach ( $ row as $ k => $ v ) { $ buffer .= '<th>' . $ k . '</th>' ; } $ buffer .= '</tr></thead><tbody>' ; $ first = false ; } $ buffer .= '<tr>' ; foreach ( $ row as $ k => $ v ) { $ buffer .= '<td>' . $ v . '</td>' ; } $ buffer .= '</tr>' ; } $ buffer .= '</tbody></table>' ; $ this -> sql = $ backup ; $ this -> freeResult ( $ cursor ) ; return $ buffer ; }
Diagnostic method to return explain information for a query.
Diagnostic method to return explain information for a query .
// Deprecation warning. // Backup the current query so we can reset it later. // Prepend the current query with EXPLAIN so we get the diagnostic data. // Execute the query and get the result set cursor. // Build the HTML table. // Restore the original query to it's state before we ran the explain. // Free up system resources and return.