/** * 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()))); }); }
/** * @param array $values * @param string $key * @return Update $this */ public function setMultiple(array $values, $key = 'id') { $values = Arr::flipNested($values); foreach ($values as $column => $changes) { $this->set[] = new SQL\SetMultiple($column, $changes, $key); } return $this; }
/** * 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)); }
/** * Get parameters from Parametrised objects * @param array $items * @return array */ public static function parameters(array $items) { $parameters = array(); $items = array_filter(Arr::flatten($items)); foreach ($items as $item) { $itemParams = $item->getParameters(); if ($itemParams !== null) { $parameters[] = $itemParams; } } return Arr::flatten($parameters); }
/** * 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 dataDisassociate * @covers ::disassociate */ public function testDisassociate($array, $expected) { $this->assertEquals($expected, Arr::disassociate($array)); }
public function getParameters() { return Arr::disassociate($this->getValue()); }