@@ -48,6 +48,9 @@ |
||
48 | 48 | |
49 | 49 | class OrderByRule extends LimitRule |
50 | 50 | { |
51 | + /** |
|
52 | + * @param Context $context |
|
53 | + */ |
|
51 | 54 | public function __construct($context){ |
52 | 55 | parent::__construct($context); |
53 | 56 | $this->impl = new OrderByImpl(); |
@@ -49,7 +49,6 @@ discard block |
||
49 | 49 | |
50 | 50 | /** |
51 | 51 | * where 语法见 @see WhereRule |
52 | - * @param array|string $expr |
|
53 | 52 | * @param mixed|null $_ |
54 | 53 | * @return \PhpBoot\DB\rules\basic\WhereRule |
55 | 54 | */ |
@@ -91,7 +90,7 @@ discard block |
||
91 | 90 | /** |
92 | 91 | * @param int|string $id |
93 | 92 | * @param array $values |
94 | - * @return int updated row count |
|
93 | + * @return \PhpBoot\DB\impls\ExecResult updated row count |
|
95 | 94 | */ |
96 | 95 | public function update($id, $values) |
97 | 96 | { |
@@ -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) { |
@@ -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(); |
@@ -8,6 +8,11 @@ discard block |
||
8 | 8 | use PhpBoot\DB\Context; |
9 | 9 | |
10 | 10 | class ExecResult{ |
11 | + |
|
12 | + /** |
|
13 | + * @param \PDO $pdo |
|
14 | + * @param \PDOStatement $st |
|
15 | + */ |
|
11 | 16 | public function __construct($success, $pdo, $st){ |
12 | 17 | $this->pdo = $pdo; |
13 | 18 | $this->st = $st; |
@@ -41,6 +46,10 @@ discard block |
||
41 | 46 | |
42 | 47 | class SelectImpl |
43 | 48 | { |
49 | + /** |
|
50 | + * @param Context $context |
|
51 | + * @param string $columns |
|
52 | + */ |
|
44 | 53 | static public function select($context, $columns){ |
45 | 54 | $context->appendSql("SELECT $columns"); |
46 | 55 | } |
@@ -48,6 +57,10 @@ discard block |
||
48 | 57 | |
49 | 58 | class FromImpl |
50 | 59 | { |
60 | + /** |
|
61 | + * @param Context $context |
|
62 | + * @param string $tables |
|
63 | + */ |
|
51 | 64 | static public function from($context, $tables,$as=null){ |
52 | 65 | if($tables instanceof BasicRule){ |
53 | 66 | $context->appendSql("FROM (".$tables->context->sql.')'); |
@@ -63,6 +76,10 @@ discard block |
||
63 | 76 | |
64 | 77 | class DeleteImpl |
65 | 78 | { |
79 | + /** |
|
80 | + * @param Context $context |
|
81 | + * @param string $from |
|
82 | + */ |
|
66 | 83 | static public function deleteFrom($context, $from) |
67 | 84 | { |
68 | 85 | $context->appendSql("DELETE FROM ".DB::wrap($from)); |
@@ -71,6 +88,11 @@ discard block |
||
71 | 88 | |
72 | 89 | class JoinImpl |
73 | 90 | { |
91 | + /** |
|
92 | + * @param Context $context |
|
93 | + * @param null|string $type |
|
94 | + * @param string $table |
|
95 | + */ |
|
74 | 96 | static public function join($context, $type, $table) { |
75 | 97 | $table = DB::wrap($table); |
76 | 98 | if($type){ |
@@ -83,6 +105,10 @@ discard block |
||
83 | 105 | |
84 | 106 | class JoinOnImpl |
85 | 107 | { |
108 | + /** |
|
109 | + * @param Context $context |
|
110 | + * @param string $condition |
|
111 | + */ |
|
86 | 112 | static public function on($context, $condition) { |
87 | 113 | $context->appendSql("ON $condition"); |
88 | 114 | } |
@@ -90,6 +116,9 @@ discard block |
||
90 | 116 | |
91 | 117 | class ForUpdateImpl |
92 | 118 | { |
119 | + /** |
|
120 | + * @param Context $context |
|
121 | + */ |
|
93 | 122 | static public function forUpdate($context){ |
94 | 123 | $context->appendSql("FOR UPDATE"); |
95 | 124 | } |
@@ -97,6 +126,10 @@ discard block |
||
97 | 126 | |
98 | 127 | class ForUpdateOfImpl |
99 | 128 | { |
129 | + /** |
|
130 | + * @param Context $context |
|
131 | + * @param string $column |
|
132 | + */ |
|
100 | 133 | static public function of($context, $column){ |
101 | 134 | $column = DB::wrap($column); |
102 | 135 | $context->appendSql("OF $column"); |
@@ -105,6 +138,10 @@ discard block |
||
105 | 138 | |
106 | 139 | class InsertImpl |
107 | 140 | { |
141 | + /** |
|
142 | + * @param Context $context |
|
143 | + * @param string $table |
|
144 | + */ |
|
108 | 145 | static public function insertInto($context, $table) { |
109 | 146 | $table = DB::wrap($table); |
110 | 147 | $context->appendSql("INSERT INTO $table"); |
@@ -112,6 +149,10 @@ discard block |
||
112 | 149 | } |
113 | 150 | class ReplaceImpl |
114 | 151 | { |
152 | + /** |
|
153 | + * @param Context $context |
|
154 | + * @param string $table |
|
155 | + */ |
|
115 | 156 | static public function replaceInto($context, $table) { |
116 | 157 | $table = DB::wrap($table); |
117 | 158 | $context->appendSql("REPLACE INTO $table"); |
@@ -195,6 +236,10 @@ discard block |
||
195 | 236 | |
196 | 237 | class UpdateImpl |
197 | 238 | { |
239 | + /** |
|
240 | + * @param Context $context |
|
241 | + * @param string $table |
|
242 | + */ |
|
198 | 243 | static public function update($context, $table){ |
199 | 244 | $table = DB::wrap($table); |
200 | 245 | $context->appendSql("UPDATE $table"); |
@@ -211,6 +256,9 @@ discard block |
||
211 | 256 | } |
212 | 257 | } |
213 | 258 | |
259 | + /** |
|
260 | + * @param string $expr |
|
261 | + */ |
|
214 | 262 | public function setExpr(Context $context, $expr, $args){ |
215 | 263 | if($this->first){ |
216 | 264 | $this->first = false; |
@@ -273,6 +321,11 @@ discard block |
||
273 | 321 | } |
274 | 322 | return $this; |
275 | 323 | } |
324 | + |
|
325 | + /** |
|
326 | + * @param string $column |
|
327 | + * @param string $order |
|
328 | + */ |
|
276 | 329 | public function orderBy(Context $context, $column, $order=null){ |
277 | 330 | if(is_string($column)){ |
278 | 331 | if($order === null){ |
@@ -290,12 +343,20 @@ discard block |
||
290 | 343 | |
291 | 344 | class LimitImpl |
292 | 345 | { |
346 | + /** |
|
347 | + * @param integer $size |
|
348 | + */ |
|
293 | 349 | static public function limit(Context $context, $size){ |
294 | 350 | $intSize = intval($size); |
295 | 351 | strval($intSize) == $size or \PhpBoot\abort( |
296 | 352 | new \InvalidArgumentException("invalid params for limit($size)")); |
297 | 353 | $context->appendSql("LIMIT $size"); |
298 | 354 | } |
355 | + |
|
356 | + /** |
|
357 | + * @param integer $start |
|
358 | + * @param integer $size |
|
359 | + */ |
|
299 | 360 | static public function limitWithOffset(Context $context, $start, $size){ |
300 | 361 | $intStart = intval($start); |
301 | 362 | $intSize = intval($size); |
@@ -307,6 +368,9 @@ discard block |
||
307 | 368 | |
308 | 369 | class WhereImpl{ |
309 | 370 | |
371 | + /** |
|
372 | + * @param string $str |
|
373 | + */ |
|
310 | 374 | static private function findQ($str,$offset = 0,$no=0){ |
311 | 375 | $found = strpos($str, '?', $offset); |
312 | 376 | if($no == 0 || $found === false){ |
@@ -315,6 +379,9 @@ discard block |
||
315 | 379 | return self::findQ($str, $found+1, $no-1); |
316 | 380 | } |
317 | 381 | |
382 | + /** |
|
383 | + * @param string $prefix |
|
384 | + */ |
|
318 | 385 | static public function where(Context $context, $prefix, $expr, $args){ |
319 | 386 | if(empty($expr)){ |
320 | 387 | return; |
@@ -433,6 +500,10 @@ discard block |
||
433 | 500 | |
434 | 501 | self::condition($context, $prefix, implode(' AND ', $exprs), $params); |
435 | 502 | } |
503 | + |
|
504 | + /** |
|
505 | + * @param string $expr |
|
506 | + */ |
|
436 | 507 | static public function condition(Context $context, $prefix, $expr, $args){ |
437 | 508 | if(!empty($expr)){ |
438 | 509 | $expr = "($expr)"; |
@@ -505,6 +576,10 @@ discard block |
||
505 | 576 | } |
506 | 577 | |
507 | 578 | class GroupByImpl{ |
579 | + |
|
580 | + /** |
|
581 | + * @param string $column |
|
582 | + */ |
|
508 | 583 | static public function groupBy(Context $context, $column){ |
509 | 584 | $column = DB::wrap($column); |
510 | 585 | $context->appendSql("GROUP BY $column"); |
@@ -527,7 +602,6 @@ discard block |
||
527 | 602 | /** |
528 | 603 | * |
529 | 604 | * @param Context $context |
530 | - * @param string|false $asDict return as dict or array |
|
531 | 605 | * @return false|array |
532 | 606 | */ |
533 | 607 | static public function get($context, $dictAs=false){ |
@@ -586,6 +660,9 @@ discard block |
||
586 | 660 | } |
587 | 661 | class OnDuplicateKeyUpdateImpl |
588 | 662 | { |
663 | + /** |
|
664 | + * @param Context $context |
|
665 | + */ |
|
589 | 666 | public function set($context, $column, $value){ |
590 | 667 | if(is_string($column)){ |
591 | 668 | $this->setExpr($context, $column, $value); |
@@ -594,6 +671,9 @@ discard block |
||
594 | 671 | } |
595 | 672 | } |
596 | 673 | |
674 | + /** |
|
675 | + * @param string $expr |
|
676 | + */ |
|
597 | 677 | public function setExpr($context, $expr, $args){ |
598 | 678 | $prefix = ''; |
599 | 679 | if($this->first){ |
@@ -64,6 +64,9 @@ |
||
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
67 | + /** |
|
68 | + * @param string|null $name |
|
69 | + */ |
|
67 | 70 | public function getParamMeta($name) |
68 | 71 | { |
69 | 72 | foreach ($this->paramMetas as $meta){ |
@@ -37,7 +37,7 @@ |
||
37 | 37 | return $factory->make(self::class); |
38 | 38 | } |
39 | 39 | /** |
40 | - * @param $className |
|
40 | + * @param string $className |
|
41 | 41 | * @throws \Exception |
42 | 42 | */ |
43 | 43 | public function loadCommandsFromClass($className) |