Fix for JDatabaseQuery->union method.

Backport of #2735 to Joomla 2.5.  See also tracker #32995.
Also backports the JDatabaseQuery->unionAll method.