API16

JDatabaseMySQL/explain

< API16:JDatabaseMySQL

The "API16" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description

Diagnostic function


<! removed transcluded page call, red link never existed >

Syntax

explain()


Returns

string

Defined in

libraries/joomla/database/database/mysql.php

Importing

jimport( 'joomla.database.database.mysql' );

Source Body

public function explain()
{
        $temp = $this->_sql;
        $this->_sql = "EXPLAIN $this->_sql";

        if (!($cur = $this->query())) {
                return null;
        }
        $first = true;

        $buffer = '<table id="explain-sql">';
        $buffer .= '<thead><tr><td colspan="99">'.$this->getQuery().'</td></tr>';
        while ($row = mysql_fetch_assoc($cur)) {
                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>';
        mysql_free_result($cur);

        $this->_sql = $temp;

        return $buffer;
}


<! removed transcluded page call, red link never existed >

Examples

Code Examples


Advertisement