Пример #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
 /**
  * @param array  $values
  * @param string $key
  * @return Update        $this
  */
 public function setMultiple(array $values, $key = 'id')
 {
     $values = Arr::flipNested($values);
     foreach ($values as $column => $changes) {
         $this->set[] = new SQL\SetMultiple($column, $changes, $key);
     }
     return $this;
 }
Пример #3
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));
 }
Пример #4
0
 /**
  * Get parameters from Parametrised objects
  * @param  array  $items
  * @return array
  */
 public static function parameters(array $items)
 {
     $parameters = array();
     $items = array_filter(Arr::flatten($items));
     foreach ($items as $item) {
         $itemParams = $item->getParameters();
         if ($itemParams !== null) {
             $parameters[] = $itemParams;
         }
     }
     return Arr::flatten($parameters);
 }
Пример #5
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())));
 }
Пример #6
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));
 }
Пример #7
0
 /**
  * @dataProvider dataDisassociate
  * @covers ::disassociate
  */
 public function testDisassociate($array, $expected)
 {
     $this->assertEquals($expected, Arr::disassociate($array));
 }
Пример #8
0
 public function getParameters()
 {
     return Arr::disassociate($this->getValue());
 }