Thread:Project:Support desk/Mediawiki Database abstraction layer wrapper functions: how to CREATE TEMPORARY TABLE/reply

Looks like  has what you want, but the temporary table bit should be abstracted out.