示例#1
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));
 }
示例#2
0
文件: Select.php 项目: harp-orm/query
 /**
  * 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())));
     });
 }
示例#3
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())));
     });
 }
示例#4
0
 /**
  * @dataProvider dataExpandParameterArrays
  * @covers ::expandParameterArrays
  */
 public function testExpandParameterArrays($content, $parameters, $expected)
 {
     $this->assertEquals($expected, Compiler\Condition::expandParameterArrays($content, $parameters));
 }