Пример #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())));
     });
 }
Пример #2
0
 /**
  * Render the value of Set object
  * @param  SQL\Set $item
  * @return string
  */
 public static function renderValue(SQL\Set $item)
 {
     $value = $item->getValue();
     $content = $item->getContent();
     if ($value instanceof SQL\SQL) {
         return $value->getContent();
     } elseif ($value instanceof Query\Select) {
         return Compiler::braced(Select::render($value));
     } elseif ($item instanceof SQL\SetMultiple and is_string($content)) {
         return self::renderMultiple($value, $content, $item->getKey());
     } else {
         return '?';
     }
 }
Пример #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())));
 }
Пример #4
0
 /**
  * @dataProvider dataBraced
  * @covers ::braced
  */
 public function testBraced($statement, $expected)
 {
     $this->assertEquals($expected, Compiler::braced($statement));
 }