Returns the number of rows from a select count() query and is called from the objSQL class. This helper method is dependant on the named connection instance and can be called anywhere within a query block.
int obj_row_count ( str table[, str cols[, str where ]] )
Unsigned integer or -1 on failure.
<?php
try
{
$num_rows = $dbh->obj_row_count( "mytable", "id", "l_name='Jones'" );
if ( $dbh->obj_error() )
throw new Exception( $dbh->obj_error_message() );
echo "<p>Your query returned $num_rows results</p>";
}
catch ( Exception $e )
{
//log error and/or redirect user to error page
}
try
{
//set arguments using statement argument helper methods
$dbh->obj_table( "mytable" );
$dbh->obj_cols( "id" );
$dbh->obj_where( "l_name='Jones'" );
$num_rows = $dbh->obj_row_count();
if ( $dbh->obj_error() )
throw new Exception( $dbh->obj_error_message() );
echo "<p>Your query returned $num_rows results</p>";
}
catch ( Exception $e )
{
//log error and/or redirect user to error page
}
?>
See also: obj_affected_rows, obj_num_fields, obj_num_rows