/** * Render a Union object * @param Query\Union $query * @return string */ public static function render(Query\Union $query) { return Compiler::withDb($query->getDb(), function () use($query) { return Compiler::expression(array(Arr::join(' UNION ', Arr::map(function (Query\Select $select) { return Compiler::braced(Select::render($select)); }, $query->getSelects())), Compiler::word('ORDER BY', Direction::combine($query->getOrder())), Compiler::word('LIMIT', $query->getLimit()))); }); }
/** * Render multiple Condition objects * * @param SQL\Condition[]|null $conditions * @return string|null */ public static function combine($conditions) { return Arr::join(' AND ', Arr::map(function ($condition) { return "(" . Condition::render($condition) . ")"; }, $conditions)); }
/** * Render Columns object * @param SQL\Columns $item * @return string */ public static function renderItem(SQL\Columns $item) { return Compiler::braced(Arr::join(', ', Arr::map(__NAMESPACE__ . '\\Compiler::name', $item->all()))); }
/** * Render Multiple Aliased objects * * @param SQL\Aliased[]|null $items * @return string|null */ public static function combine($items) { return Arr::join(', ', Arr::map(__CLASS__ . '::render', $items)); }
/** * @dataProvider dataJoin * @covers ::join */ public function testJoin($separator, $array, $expected) { $this->assertEquals($expected, Arr::join($separator, $array)); }