The Scenario I have completely rewritten an old existing ASP classic ecommerce website over to PHP.
The database design of the previous site had
Your query:
SELECT ID FROM thetable WHERE ProductID=?
From there just echo the value of ID and a newline, and flush stdout.
ID
Rewrite rules:
RewriteMap dbfixup prg:dbfixup.script RewriteCond %{QUERY_STRING} ProductID=(\d+) RewriteRule Product.asp Products.php?ID=${dbfixup:%1}