[REVIEW] database->getNumRows

Last reviewed: Not reviewed
phpDocumentor

database->getNumRows

Returns the number of rows returned by the most recent database query or from a specified database resource.

Syntax

int getNumRows ( [ object $resource] )

$resource
is a database resource object.  This parameter is optional and if omitted the function will return the number of rows from the most recent database query.

Examples

Example: A function to count the number of registered users.  Of course, this function could be performed more efficiently using a "SELECT count(*) FROM #__users" query.

// Return total number of users registered on the site.
function countUsers() {
  global $database;
 
  $database->setQuery( "SELECT id FROM #__users" );
  if (!$database->query()) {
    echo $database->stderr();
    return false;
  }
  return $database->getNumRows();
}

Please report any errors on this page to the Developer Documentation Forum.

 

Last Updated ( Monday, 25 December 2006 )