Actions

API15

JDatabaseMySQLi/explain

From Joomla! Documentation

< API15:JDatabaseMySQLi
Revision as of 17:15, 22 March 2010 by Doxiki (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Description

Diagnostic function

[Edit Descripton]

Description:JDatabaseMySQLi/explain

Syntax

explain()


Returns

string

Defined in

libraries/joomla/database/database/mysqli.php

Importing

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

Source Body

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 = mysqli_fetch_assoc( $cur )) {
                if ($first) {
                        $buffer .= '<tr>';
                        foreach ($row as $k=>$v) {
                                $buffer .= '<th>'.$k.'</th>';
                        }
                        $buffer .= '</tr>';
                        $first = false;
                }
                $buffer .= '</thead><tbody><tr>';
                foreach ($row as $k=>$v) {
                        $buffer .= '<td>'.$v.'</td>';
                }
                $buffer .= '</tr>';
        }
        $buffer .= '</tbody></table>';
        mysqli_free_result( $cur );
 
        $this->_sql = $temp;
 
        return $buffer;
}

[Edit See Also] SeeAlso:JDatabaseMySQLi/explain

Examples

<CodeExamplesForm />