コード例 #1
0
ファイル: Union.php プロジェクト: harp-orm/query
 /**
  * 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
ファイル: Update.php プロジェクト: harp-orm/query
 /**
  * @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
ファイル: Condition.php プロジェクト: harp-orm/query
 /**
  * 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
ファイル: Compiler.php プロジェクト: harp-orm/query
 /**
  * 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
ファイル: Columns.php プロジェクト: harp-orm/query
 /**
  * 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
ファイル: Aliased.php プロジェクト: harp-orm/query
 /**
  * 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
ファイル: ArrTest.php プロジェクト: harp-orm/query
 /**
  * @dataProvider dataDisassociate
  * @covers ::disassociate
  */
 public function testDisassociate($array, $expected)
 {
     $this->assertEquals($expected, Arr::disassociate($array));
 }
コード例 #8
0
ファイル: SetMultiple.php プロジェクト: harp-orm/query
 public function getParameters()
 {
     return Arr::disassociate($this->getValue());
 }