Regarding bailing on a really large result, while doing an unbuffered query, there _is_ a way to do this: kill the thread and exit your processing loop.  This, of course, requires having a separate database link.  Something like below does the trick:
<?php
$lh  = mysql_connect( 'server', 'uname', 'pword' );
$clh = mysql_connect( 'server', 'uname', 'pword', true );
if ( mysql_select_db ( 'big_database', $lh ) )
{
  $began  =  time();
  $tout   = 60 * 5; $qry    = "SELECT * FROM my_bigass_table";
  $rh     = mysql_unbuffered_query( $qry, $lh );
  $thread = mysql_thread_id ( $lh );
  while ( $res = mysql_fetch_row( $rh ) )
  {
    if ( ( time() - $began ) > $tout )
    {
      mysql_query( "KILL $thread", $clh );
      break;
    }
  }
}
?>