<?php
$wheres[] = 'SELECT * FROM x';
$wheres[] = 'SELECT * FROM y';
$wheres[] = 'SELECT * FROM z';
$wheres_compiled = implode(' UNION ', $wheres);
PD9waHAKCiR3aGVyZXNbXSA9ICdTRUxFQ1QgKiBGUk9NIHgnOwokd2hlcmVzW10gPSAnU0VMRUNUICogRlJPTSB5JzsKJHdoZXJlc1tdID0gJ1NFTEVDVCAqIEZST00geic7Cgokd2hlcmVzX2NvbXBpbGVkID0gaW1wbG9kZSgnIFVOSU9OICcsICR3aGVyZXMpOwoKdmFyX2R1bXAoJHdoZXJlc19jb21waWxlZCk7