Table of Contents

query

API Package Subpackage Class Method Reference Last reviewed Doc status
API Home Package Joomla.Framework Subpackage Database Class JDatabase Method query Reference query() Never Work in Progress

Executes the current SQL query string. This method returns a database resource if successful, false otherwise.

The syntax and semantics of SQL statements are beyond the scope of this manual. Prior to Joomla! 1.5 the only database software supported was MySQL and the reference manual may be found at http://dev.mysql.com/doc/.

Syntax

mixed query()

Examples

Example

$database =& JFactory::getDBO();

$sql = "SELECT * FROM #__categories";
$database->setQuery( $sql );
if (!$result = $database->query()) {
  echo $database->stderr();
}

echo $database->getNumRows( $result );

might produce:

Result

23