Rewriting mysql_query to mysql_unbuffered_query