/** * Method: union * Adds an UNION to the query * * @param Query | string $select can be an Query object or string containing * a query * @throws Exception */ public function union($select = array()) { if (!array_key_exists(self::UNION, $this->_querystack)) { throw new Exception("Cant use UNION here"); } if ($select instanceof Query) { if ($select->_type() != self::SELECT) { throw new Exception("Queryobject is not a SELECT Type"); } $this->_querystack[self::UNION][] = $select->_toString(); } elseif (is_array($select)) { foreach ($select as $stmt) { if ($stmt instanceof Query) { if ($select->_type() != self::SELECT) { throw new Exception("Queryobject is not a SELECT Type"); } $this->_querystack[self::UNION][] = $select->_toString(); } else { $this->_querystack[self::UNION][] = $stmt; } } } else { $this->_querystack[self::UNION][] = $select; } return $this; }