示例#1
0
文件: Insert.php 项目: harp-orm/query
 /**
  * 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
文件: Update.php 项目: harp-orm/query
 /**
  * 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
 /**
  * @dataProvider dataRenderValue
  * @covers ::renderValue
  * @covers ::renderMultiple
  */
 public function testRenderValue($item, $expected)
 {
     $this->assertEquals($expected, Compiler\Set::renderValue($item));
 }