This is a nice feature Cold Fusion has that PHP doesn't. What I do is create a global variable to keep the count, and just increment it everytime I do a query.
$r=odbc_exec($h,$sql); $GLOBALS['querycount']++;
I actually have this as a macro in my editor.