API15

JDatabaseMySQLi/explain: Difference between revisions

From Joomla! Documentation

m removing red link to edit, no existant pages
m preparing for archive only
 
Line 64: Line 64:


===Examples===
===Examples===
<CodeExamplesForm />
=== Code Examples ===
<dpl>
<dpl>
  noresultsheader=\n
  noresultsheader=\n
  category=explain
  category=explain
  category=JDatabaseMySQLi
  category=JDatabaseMySQLi
  category=CodeExample
  namespace=CodeExample
  category=MethodExample
  category=MethodExample
  include=*
  include=*

Latest revision as of 00:28, 25 March 2017

Description

Diagnostic function

[<! removed edit link to red link >]

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

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;
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples

Code Examples