Пример #1
0
 /**
  * Render a Insert object
  * @param  Query\Insert $query
  * @return string
  */
 public static function render(Query\Insert $query)
 {
     return Compiler::withDb($query->getDb(), function () use($query) {
         $table = $query->getTable();
         $select = $query->getSelect();
         return Compiler::expression(array('INSERT', $query->getType(), Compiler::word('INTO', $table !== null ? Aliased::render($table) : null), Columns::render($query->getColumns()), Compiler::word('VALUES', Values::combine($query->getValues())), Compiler::word('SET', Set::combine($query->getSet())), $select !== null ? Select::render($select) : null));
     });
 }
Пример #2
0
 /**
  * Render Update object
  * @param  Query\Update $query
  * @return string
  */
 public static function render(Query\Update $query)
 {
     return Compiler::withDb($query->getDb(), function () use($query) {
         return Compiler::expression(array('UPDATE', $query->getType(), Aliased::combine($query->getTable()), Join::combine($query->getJoin()), Compiler::word('SET', Set::combine($query->getSet())), Compiler::word('WHERE', Condition::combine($query->getWhere())), Compiler::word('ORDER BY', Direction::combine($query->getOrder())), Compiler::word('LIMIT', $query->getLimit())));
     });
 }
Пример #3
0
 /**
  * Render a Select object
  * @param  Query\Select $query
  * @return string
  */
 public static function render(Query\Select $query)
 {
     return Compiler::withDb($query->getDb(), function () use($query) {
         return Compiler::expression(array('SELECT', $query->getType(), Aliased::combine($query->getColumns()) ?: '*', Compiler::word('FROM', Aliased::combine($query->getFrom())), Join::combine($query->getJoin()), Compiler::word('WHERE', Condition::combine($query->getWhere())), Compiler::word('GROUP BY', Direction::combine($query->getGroup())), Compiler::word('HAVING', Condition::combine($query->getHaving())), Compiler::word('ORDER BY', Direction::combine($query->getOrder())), Compiler::word('LIMIT', $query->getLimit()), Compiler::word('OFFSET', $query->getOffset())));
     });
 }
Пример #4
0
 /**
  * Render a Join object
  *
  * @param  SQL\Join $join
  * @return string
  */
 public static function render(SQL\Join $join)
 {
     $condition = $join->getCondition();
     $table = $join->getTable();
     return Compiler::expression(array($join->getType(), 'JOIN', $table instanceof SQL\Aliased ? Aliased::render($table) : $table, is_array($condition) ? self::renderArrayCondition($condition) : $condition));
 }
Пример #5
0
 /**
  * @dataProvider dataRender
  * @covers ::render
  */
 public function testRender($content, $alias, $expected)
 {
     $aliased = new SQL\Aliased($content, $alias);
     $this->assertEquals($expected, Compiler\Aliased::render($aliased));
 }