Example #1
0
 /**
  * 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())));
     });
 }
Example #2
0
 /**
  * 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));
 }
Example #3
0
 /**
  * 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())));
 }
Example #4
0
 /**
  * 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));
 }
Example #5
0
 /**
  * @dataProvider dataJoin
  * @covers ::join
  */
 public function testJoin($separator, $array, $expected)
 {
     $this->assertEquals($expected, Arr::join($separator, $array));
 }