/** * Adds an other UNION clause. * * @param mixed $select if string, it must be the name of a table. Else must be an instance of Database_Query_Builder_Select * @param boolean $all decides if it's an UNION or UNION ALL clause * @throws \Quark\Exception\QuarkException * @return $this */ public function union($select, $all = true) { if (is_string($select)) { $qb = new Select(); $select = $qb->from($select); } if (!$select instanceof Select) { throw new QuarkException('first parameter must be a string or an instance of \\Quark\\Database\\Query\\Builder\\Select'); } $this->union[] = array('select' => $select, 'all' => $all); return $this; }
public function testResetQuery() { $query = $this->queryBuilder->distinct(true)->from(array('users', 'u'))->join(array('posts', 'p'), 'LEFT')->on('p.user_id', '=', 'u.id')->join(array('venues', 'v'), 'RIGHT')->on('v.user_id', '=', 'u.id')->where('u.name', '=', 'test')->havingOpen()->having('u.age', '>', '10')->orHaving('u.age', '<', '14')->havingClose()->orderBy('u.age', 'DESC')->limit(10)->reset()->compile(); $afterReset = "SELECT *"; $this->assertSame($afterReset, $query); }