API16

JDatabaseQuery/ toString

From Joomla! Documentation

< API16:JDatabaseQuery
Revision as of 01:29, 25 March 2017 by JoomlaWikiBot (talk | contribs) (preparing for archive only)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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[edit]

string The completed query



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

Syntax[edit]

__toString()


Returns[edit]

string The completed query

Defined in[edit]

libraries/joomla/database/databasequery.php

Importing[edit]

jimport( 'joomla.database.databasequery' );

Source Body[edit]

public function __toString()
{
        $query = '';

        switch ($this->_type) {
                case 'select':
                        $query .= (string) $this->_select;
                        $query .= (string) $this->_from;
                        if ($this->_join) {
                                // special case for joins
                                foreach ($this->_join as $join) {
                                        $query .= (string) $join;
                                }
                        }
                        if ($this->_where) {
                                $query .= (string) $this->_where;
                        }
                        if ($this->_group) {
                                $query .= (string) $this->_group;
                        }
                        if ($this->_having) {
                                $query .= (string) $this->_having;
                        }
                        if ($this->_order) {
                                $query .= (string) $this->_order;
                        }
                        break;

                case 'delete':
                        $query .= (string) $this->_delete;
                        $query .= (string) $this->_from;
                        if ($this->_where) {
                                $query .= (string) $this->_where;
                        }
                        break;

                case 'update':
                        $query .= (string) $this->_update;
                        $query .= (string) $this->_set;
                        if ($this->_where) {
                                $query .= (string) $this->_where;
                        }
                        break;

                case 'insert':
                        $query .= (string) $this->_insert;
                        $query .= (string) $this->_set;
                        if ($this->_where) {
                                $query .= (string) $this->_where;
                        }
                        break;
        }

        return $query;
}


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

Examples[edit]

Code Examples[edit]