@@ -113,6 +113,9 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | class OrderByRule extends LimitRule |
| 115 | 115 | { |
| 116 | + /** |
|
| 117 | + * @param Context $context |
|
| 118 | + */ |
|
| 116 | 119 | public function __construct($context){ |
| 117 | 120 | parent::__construct($context); |
| 118 | 121 | $this->order = new OrderByImpl(); |
@@ -260,7 +263,7 @@ discard block |
||
| 260 | 263 | * "WHERE a=1 AND b IN(1,2) AND c BETWEEN 1 AND 2 AND d<>1" |
| 261 | 264 | * |
| 262 | 265 | * @param string|array|callable $conditions |
| 263 | - * @param mixed $_ |
|
| 266 | + * @param string $_ |
|
| 264 | 267 | * @return \PhpBoot\DB\rules\select\NextWhereRule |
| 265 | 268 | */ |
| 266 | 269 | public function where($conditions=null, $_=null) { |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * @param string|false $asDict |
| 40 | 40 | * @return array |
| 41 | 41 | */ |
| 42 | - public function get($asDict=false) { |
|
| 42 | + public function get($asDict = false) { |
|
| 43 | 43 | return ExecImpl::get($this->context, $asDict); |
| 44 | 44 | } |
| 45 | 45 | |
@@ -53,9 +53,9 @@ discard block |
||
| 53 | 53 | * Execute sql and get one response |
| 54 | 54 | * @return null |
| 55 | 55 | */ |
| 56 | - public function getFirst(){ |
|
| 56 | + public function getFirst() { |
|
| 57 | 57 | $res = ExecImpl::get($this->context); |
| 58 | - if(count($res)){ |
|
| 58 | + if (count($res)) { |
|
| 59 | 59 | return $res[0]; |
| 60 | 60 | } |
| 61 | 61 | return null; |
@@ -68,8 +68,8 @@ discard block |
||
| 68 | 68 | * @param string $table |
| 69 | 69 | * @return \PhpBoot\DB\rules\select\JoinRule |
| 70 | 70 | */ |
| 71 | - public function from($table, $as=null){ |
|
| 72 | - FromImpl::from($this->context, $table,$as); |
|
| 71 | + public function from($table, $as = null) { |
|
| 72 | + FromImpl::from($this->context, $table, $as); |
|
| 73 | 73 | return new JoinRule($this->context); |
| 74 | 74 | } |
| 75 | 75 | } |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | * @param string $column |
| 81 | 81 | * @return \PhpBoot\DB\rules\select\GetRule |
| 82 | 82 | */ |
| 83 | - public function of($column){ |
|
| 83 | + public function of($column) { |
|
| 84 | 84 | ForUpdateOfImpl::of($this->context, $column); |
| 85 | 85 | return new GetRule($this->context); |
| 86 | 86 | } |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | * forUpdate() => 'FOR UPDATE' |
| 92 | 92 | * @return \PhpBoot\DB\rules\select\ForUpdateOfRule |
| 93 | 93 | */ |
| 94 | - public function forUpdate(){ |
|
| 94 | + public function forUpdate() { |
|
| 95 | 95 | ForUpdateImpl::forUpdate($this->context); |
| 96 | 96 | return new ForUpdateOfRule($this->context); |
| 97 | 97 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | class OrderByRule extends LimitRule |
| 115 | 115 | { |
| 116 | - public function __construct($context){ |
|
| 116 | + public function __construct($context) { |
|
| 117 | 117 | parent::__construct($context); |
| 118 | 118 | $this->order = new OrderByImpl(); |
| 119 | 119 | } |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | * @param string $order Sql::ORDER_BY_ASC or Sql::ORDER_BY_DESC |
| 129 | 129 | * @return \PhpBoot\DB\rules\select\OrderByRule |
| 130 | 130 | */ |
| 131 | - public function orderBy($column, $order=null) { |
|
| 131 | + public function orderBy($column, $order = null) { |
|
| 132 | 132 | $this->order->orderBy($this->context, $column, $order); |
| 133 | 133 | return $this; |
| 134 | 134 | } |
@@ -174,17 +174,17 @@ discard block |
||
| 174 | 174 | * @param string $_ |
| 175 | 175 | * @return \PhpBoot\DB\rules\select\HavingRule |
| 176 | 176 | */ |
| 177 | - public function having($expr, $_=null) { |
|
| 178 | - if(is_callable($expr)){ |
|
| 179 | - $callback = function ($context)use($expr){ |
|
| 177 | + public function having($expr, $_ = null) { |
|
| 178 | + if (is_callable($expr)) { |
|
| 179 | + $callback = function($context)use($expr){ |
|
| 180 | 180 | $rule = new ScopedQuery($context); |
| 181 | 181 | $expr($rule); |
| 182 | 182 | }; |
| 183 | 183 | $expr = $callback; |
| 184 | 184 | } |
| 185 | - if($this->isTheFirst){ |
|
| 185 | + if ($this->isTheFirst) { |
|
| 186 | 186 | WhereImpl::where($this->context, 'HAVING', $expr, array_slice(func_get_args(), 1)); |
| 187 | - }else{ |
|
| 187 | + }else { |
|
| 188 | 188 | WhereImpl::where($this->context, 'AND', $expr, array_slice(func_get_args(), 1)); |
| 189 | 189 | } |
| 190 | 190 | |
@@ -211,9 +211,9 @@ discard block |
||
| 211 | 211 | * @param string $_ |
| 212 | 212 | * @return \PhpBoot\DB\rules\select\HavingRule |
| 213 | 213 | */ |
| 214 | - public function orHaving($expr, $_=null) { |
|
| 215 | - if(is_callable($expr)){ |
|
| 216 | - $callback = function ($context)use($expr){ |
|
| 214 | + public function orHaving($expr, $_ = null) { |
|
| 215 | + if (is_callable($expr)) { |
|
| 216 | + $callback = function($context)use($expr){ |
|
| 217 | 217 | $rule = new ScopedQuery($context); |
| 218 | 218 | $expr($rule); |
| 219 | 219 | }; |
@@ -263,17 +263,17 @@ discard block |
||
| 263 | 263 | * @param mixed $_ |
| 264 | 264 | * @return \PhpBoot\DB\rules\select\NextWhereRule |
| 265 | 265 | */ |
| 266 | - public function where($conditions=null, $_=null) { |
|
| 267 | - if(is_callable($conditions)){ |
|
| 268 | - $callback = function ($context)use($conditions){ |
|
| 266 | + public function where($conditions = null, $_ = null) { |
|
| 267 | + if (is_callable($conditions)) { |
|
| 268 | + $callback = function($context)use($conditions){ |
|
| 269 | 269 | $rule = new ScopedQuery($context); |
| 270 | 270 | $conditions($rule); |
| 271 | 271 | }; |
| 272 | 272 | $conditions = $callback; |
| 273 | 273 | } |
| 274 | - if($this->isTheFirst){ |
|
| 275 | - WhereImpl::where($this->context, 'WHERE' ,$conditions, array_slice(func_get_args(), 1)); |
|
| 276 | - }else{ |
|
| 274 | + if ($this->isTheFirst) { |
|
| 275 | + WhereImpl::where($this->context, 'WHERE', $conditions, array_slice(func_get_args(), 1)); |
|
| 276 | + }else { |
|
| 277 | 277 | WhereImpl::where($this->context, 'AND', $conditions, array_slice(func_get_args(), 1)); |
| 278 | 278 | } |
| 279 | 279 | return new NextWhereRule($this->context, false); |
@@ -304,9 +304,9 @@ discard block |
||
| 304 | 304 | * |
| 305 | 305 | * @TODO orWhere 只能跟在 Where 后 |
| 306 | 306 | */ |
| 307 | - public function orWhere($conditions=null, $_=null) { |
|
| 308 | - if(is_callable($conditions)){ |
|
| 309 | - $callback = function ($context)use($conditions){ |
|
| 307 | + public function orWhere($conditions = null, $_ = null) { |
|
| 308 | + if (is_callable($conditions)) { |
|
| 309 | + $callback = function($context)use($conditions){ |
|
| 310 | 310 | $rule = new ScopedQuery($context); |
| 311 | 311 | $conditions($rule); |
| 312 | 312 | }; |
@@ -325,8 +325,8 @@ discard block |
||
| 325 | 325 | * @param string $table |
| 326 | 326 | * @return \PhpBoot\DB\rules\select\JoinOnRule |
| 327 | 327 | */ |
| 328 | - public function join($table){ |
|
| 329 | - JoinImpl::join($this->context,null, $table); |
|
| 328 | + public function join($table) { |
|
| 329 | + JoinImpl::join($this->context, null, $table); |
|
| 330 | 330 | return new JoinOnRule($this->context); |
| 331 | 331 | } |
| 332 | 332 | /** |
@@ -334,8 +334,8 @@ discard block |
||
| 334 | 334 | * @param string $table |
| 335 | 335 | * @return \PhpBoot\DB\rules\select\JoinOnRule |
| 336 | 336 | */ |
| 337 | - public function leftJoin($table){ |
|
| 338 | - JoinImpl::join($this->context,'LEFT', $table); |
|
| 337 | + public function leftJoin($table) { |
|
| 338 | + JoinImpl::join($this->context, 'LEFT', $table); |
|
| 339 | 339 | return new JoinOnRule($this->context); |
| 340 | 340 | } |
| 341 | 341 | /** |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | * @return \PhpBoot\DB\rules\select\JoinOnRule |
| 345 | 345 | */ |
| 346 | 346 | public function rightJoin($table) { |
| 347 | - JoinImpl::join($this->context,'RIGHT', $table); |
|
| 347 | + JoinImpl::join($this->context, 'RIGHT', $table); |
|
| 348 | 348 | return new JoinOnRule($this->context); |
| 349 | 349 | } |
| 350 | 350 | /** |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | * @return \PhpBoot\DB\rules\select\JoinOnRule |
| 354 | 354 | */ |
| 355 | 355 | public function innerJoin($table) { |
| 356 | - JoinImpl::join($this->context,'INNER', $table); |
|
| 356 | + JoinImpl::join($this->context, 'INNER', $table); |
|
| 357 | 357 | return new JoinOnRule($this->context); |
| 358 | 358 | } |
| 359 | 359 | } |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | * @param string $condition |
| 366 | 366 | * @return \PhpBoot\DB\rules\select\JoinRule |
| 367 | 367 | */ |
| 368 | - public function on($condition){ |
|
| 368 | + public function on($condition) { |
|
| 369 | 369 | JoinOnImpl::on($this->context, $condition); |
| 370 | 370 | return new JoinRule($this->context); |
| 371 | 371 | } |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | } |
| 185 | 185 | if($this->isTheFirst){ |
| 186 | 186 | WhereImpl::where($this->context, 'HAVING', $expr, array_slice(func_get_args(), 1)); |
| 187 | - }else{ |
|
| 187 | + } else{ |
|
| 188 | 188 | WhereImpl::where($this->context, 'AND', $expr, array_slice(func_get_args(), 1)); |
| 189 | 189 | } |
| 190 | 190 | |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | } |
| 274 | 274 | if($this->isTheFirst){ |
| 275 | 275 | WhereImpl::where($this->context, 'WHERE' ,$conditions, array_slice(func_get_args(), 1)); |
| 276 | - }else{ |
|
| 276 | + } else{ |
|
| 277 | 277 | WhereImpl::where($this->context, 'AND', $conditions, array_slice(func_get_args(), 1)); |
| 278 | 278 | } |
| 279 | 279 | return new NextWhereRule($this->context, false); |
@@ -25,6 +25,9 @@ |
||
| 25 | 25 | |
| 26 | 26 | class UpdateSetRule extends BasicRule |
| 27 | 27 | { |
| 28 | + /** |
|
| 29 | + * @param Context $context |
|
| 30 | + */ |
|
| 28 | 31 | public function __construct($context){ |
| 29 | 32 | parent::__construct($context); |
| 30 | 33 | $this->impl = new UpdateSetImpl(); |
@@ -31,7 +31,6 @@ discard block |
||
| 31 | 31 | } |
| 32 | 32 | /** |
| 33 | 33 | * update('table')->set(['a'=>1]) => "UPDATE table SET a=1" |
| 34 | - |
|
| 35 | 34 | * update('table')->set('a=?',1) => "UPDATE table SET a=1" |
| 36 | 35 | * @param array|string $expr |
| 37 | 36 | * @param mixed $_ |
@@ -52,7 +51,6 @@ discard block |
||
| 52 | 51 | } |
| 53 | 52 | /** |
| 54 | 53 | * update('table')->set(['a'=>1]) => "UPDATE table SET a=1" |
| 55 | - |
|
| 56 | 54 | * update('table')->set('a=?',1) => "UPDATE table SET a=1" |
| 57 | 55 | * @param array|string $expr |
| 58 | 56 | * @param mixed $_ |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | class UpdateSetRule extends BasicRule |
| 27 | 27 | { |
| 28 | - public function __construct($context){ |
|
| 28 | + public function __construct($context) { |
|
| 29 | 29 | parent::__construct($context); |
| 30 | 30 | $this->impl = new UpdateSetImpl(); |
| 31 | 31 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * @param mixed $_ |
| 38 | 38 | * @return UpdateSetWhereRule |
| 39 | 39 | */ |
| 40 | - public function set($expr, $_=null) { |
|
| 40 | + public function set($expr, $_ = null) { |
|
| 41 | 41 | $this->impl->set($this->context, $expr, array_slice(func_get_args(), 1)); |
| 42 | 42 | return new UpdateSetWhereRule($this->context, $this->impl); |
| 43 | 43 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | class UpdateSetWhereRule extends WhereRule |
| 48 | 48 | { |
| 49 | - public function __construct(Context $context, UpdateSetImpl $impl){ |
|
| 49 | + public function __construct(Context $context, UpdateSetImpl $impl) { |
|
| 50 | 50 | parent::__construct($context); |
| 51 | 51 | $this->impl = $impl; |
| 52 | 52 | } |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * @param mixed $_ |
| 59 | 59 | * @return WhereRule |
| 60 | 60 | */ |
| 61 | - public function set($expr, $_=null) { |
|
| 61 | + public function set($expr, $_ = null) { |
|
| 62 | 62 | $this->impl->set($this->context, $expr, array_slice(func_get_args(), 1)); |
| 63 | 63 | return new UpdateSetWhereRule($this->context, $this->impl); |
| 64 | 64 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | class BasicRule |
| 13 | 13 | { |
| 14 | - public function __construct(Context $context){ |
|
| 14 | + public function __construct(Context $context) { |
|
| 15 | 15 | $this->context = $context; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | class OrderByRule extends LimitRule |
| 50 | 50 | { |
| 51 | - public function __construct($context){ |
|
| 51 | + public function __construct($context) { |
|
| 52 | 52 | parent::__construct($context); |
| 53 | 53 | $this->impl = new OrderByImpl(); |
| 54 | 54 | } |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | * |
| 64 | 64 | * @return \PhpBoot\DB\rules\basic\LimitRule |
| 65 | 65 | */ |
| 66 | - public function orderBy($column, $order=null) { |
|
| 66 | + public function orderBy($column, $order = null) { |
|
| 67 | 67 | $this->impl->orderBy($this->context, $column, $order); |
| 68 | 68 | return new LimitRule($this->context); |
| 69 | 69 | } |
@@ -95,17 +95,17 @@ discard block |
||
| 95 | 95 | * @param mixed $_ |
| 96 | 96 | * @return NextWhereRule |
| 97 | 97 | */ |
| 98 | - public function where($conditions=null, $_=null) { |
|
| 99 | - if(is_callable($conditions)){ |
|
| 100 | - $callback = function ($context)use($conditions){ |
|
| 98 | + public function where($conditions = null, $_ = null) { |
|
| 99 | + if (is_callable($conditions)) { |
|
| 100 | + $callback = function($context)use($conditions){ |
|
| 101 | 101 | $rule = new ScopedQuery($context); |
| 102 | 102 | $conditions($rule); |
| 103 | 103 | }; |
| 104 | 104 | $conditions = $callback; |
| 105 | 105 | } |
| 106 | - if($this->isTheFirst){ |
|
| 107 | - WhereImpl::where($this->context, 'WHERE' ,$conditions, array_slice(func_get_args(), 1)); |
|
| 108 | - }else{ |
|
| 106 | + if ($this->isTheFirst) { |
|
| 107 | + WhereImpl::where($this->context, 'WHERE', $conditions, array_slice(func_get_args(), 1)); |
|
| 108 | + }else { |
|
| 109 | 109 | WhereImpl::where($this->context, 'AND', $conditions, array_slice(func_get_args(), 1)); |
| 110 | 110 | } |
| 111 | 111 | return new NextWhereRule($this->context, false); |
@@ -133,9 +133,9 @@ discard block |
||
| 133 | 133 | * @param mixed $_ |
| 134 | 134 | * @return WhereRule |
| 135 | 135 | */ |
| 136 | - public function orWhere($conditions=null, $_=null) { |
|
| 137 | - if(is_callable($conditions)){ |
|
| 138 | - $callback = function ($context)use($conditions){ |
|
| 136 | + public function orWhere($conditions = null, $_ = null) { |
|
| 137 | + if (is_callable($conditions)) { |
|
| 138 | + $callback = function($context)use($conditions){ |
|
| 139 | 139 | $rule = new ScopedQuery($context); |
| 140 | 140 | $conditions($rule); |
| 141 | 141 | }; |
@@ -160,17 +160,17 @@ discard block |
||
| 160 | 160 | * @param null $_ |
| 161 | 161 | * @return NextScopedQuery |
| 162 | 162 | */ |
| 163 | - public function where($expr, $_= null){ |
|
| 164 | - if(is_callable($expr)){ |
|
| 165 | - $callback = function ($context)use($expr){ |
|
| 163 | + public function where($expr, $_ = null) { |
|
| 164 | + if (is_callable($expr)) { |
|
| 165 | + $callback = function($context)use($expr){ |
|
| 166 | 166 | $rule = new ScopedQuery($context, true); |
| 167 | 167 | $expr($rule); |
| 168 | 168 | }; |
| 169 | 169 | $expr = $callback; |
| 170 | 170 | } |
| 171 | - if($this->isTheFirst){ |
|
| 171 | + if ($this->isTheFirst) { |
|
| 172 | 172 | WhereImpl::where($this->context, '', $expr, array_slice(func_get_args(), 1)); |
| 173 | - }else{ |
|
| 173 | + }else { |
|
| 174 | 174 | WhereImpl::where($this->context, 'AND', $expr, array_slice(func_get_args(), 1)); |
| 175 | 175 | } |
| 176 | 176 | return new NextScopedQuery($this->context, false); |
@@ -186,9 +186,9 @@ discard block |
||
| 186 | 186 | * @param null $_ |
| 187 | 187 | * @return ScopedQuery |
| 188 | 188 | */ |
| 189 | - public function orWhere($expr, $_= null){ |
|
| 190 | - if(is_callable($expr)){ |
|
| 191 | - $callback = function ($context)use($expr){ |
|
| 189 | + public function orWhere($expr, $_ = null) { |
|
| 190 | + if (is_callable($expr)) { |
|
| 191 | + $callback = function($context)use($expr){ |
|
| 192 | 192 | $rule = new ScopedQuery($context, true); |
| 193 | 193 | $expr($rule); |
| 194 | 194 | }; |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | } |
| 106 | 106 | if($this->isTheFirst){ |
| 107 | 107 | WhereImpl::where($this->context, 'WHERE' ,$conditions, array_slice(func_get_args(), 1)); |
| 108 | - }else{ |
|
| 108 | + } else{ |
|
| 109 | 109 | WhereImpl::where($this->context, 'AND', $conditions, array_slice(func_get_args(), 1)); |
| 110 | 110 | } |
| 111 | 111 | return new NextWhereRule($this->context, false); |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | } |
| 171 | 171 | if($this->isTheFirst){ |
| 172 | 172 | WhereImpl::where($this->context, '', $expr, array_slice(func_get_args(), 1)); |
| 173 | - }else{ |
|
| 173 | + } else{ |
|
| 174 | 174 | WhereImpl::where($this->context, 'AND', $expr, array_slice(func_get_args(), 1)); |
| 175 | 175 | } |
| 176 | 176 | return new NextScopedQuery($this->context, false); |