Actions

API16

JDatabaseMySQL/query

From Joomla! Documentation

< API16:JDatabaseMySQL
Revision as of 17:40, 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

Execute the query

[Edit Descripton]

Description:JDatabaseMySQL/query

Syntax

query()


Returns

mixed A database resource if successful, FALSE if not.

Defined in

libraries/joomla/database/database/mysql.php

Importing

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

Source Body

public function query()
{
        if (!is_resource($this->_connection)) {
                return false;
        }
 
        // Take a local copy so that we don't modify the original query and cause issues later
        $sql = $this->replacePrefix((string) $this->_sql);
        if ($this->_limit > 0 || $this->_offset > 0) {
                $sql .= ' LIMIT '.$this->_offset.', '.$this->_limit;
        }
        if ($this->_debug) {
                $this->_ticker++;
                $this->_log[] = $sql;
        }
        $this->_errorNum = 0;
        $this->_errorMsg = '';
        $this->_cursor = mysql_query($sql, $this->_connection);
 
        if (!$this->_cursor) {
                $this->_errorNum = mysql_errno($this->_connection);
                $this->_errorMsg = mysql_error($this->_connection)." SQL=$sql";
 
                if ($this->_debug) {
                        JError::raiseError(500, 'JDatabaseMySQL::query: '.$this->_errorNum.' - '.$this->_errorMsg);
                }
                return false;
        }
        return $this->_cursor;
}

[Edit See Also] SeeAlso:JDatabaseMySQL/query

Examples

<CodeExamplesForm />