@@ -9,6 +9,12 @@ discard block |
||
9 | 9 | use PhpBoot\DB\Context; |
10 | 10 | |
11 | 11 | class ExecResult{ |
12 | + |
|
13 | + /** |
|
14 | + * @param boolean $success |
|
15 | + * @param \PDO $pdo |
|
16 | + * @param \PDOStatement $st |
|
17 | + */ |
|
12 | 18 | public function __construct($success, $pdo, $st){ |
13 | 19 | $this->pdo = $pdo; |
14 | 20 | $this->st = $st; |
@@ -42,6 +48,10 @@ discard block |
||
42 | 48 | |
43 | 49 | class SelectImpl |
44 | 50 | { |
51 | + /** |
|
52 | + * @param Context $context |
|
53 | + * @param string $columns |
|
54 | + */ |
|
45 | 55 | static public function select($context, $columns){ |
46 | 56 | $context->appendSql("SELECT $columns"); |
47 | 57 | } |
@@ -49,6 +59,10 @@ discard block |
||
49 | 59 | |
50 | 60 | class FromImpl |
51 | 61 | { |
62 | + /** |
|
63 | + * @param Context $context |
|
64 | + * @param string $tables |
|
65 | + */ |
|
52 | 66 | static public function from($context, $tables,$as=null){ |
53 | 67 | if($tables instanceof BasicRule){ |
54 | 68 | $context->appendSql("FROM (".$tables->context->sql.')'); |
@@ -64,6 +78,10 @@ discard block |
||
64 | 78 | |
65 | 79 | class DeleteImpl |
66 | 80 | { |
81 | + /** |
|
82 | + * @param Context $context |
|
83 | + * @param string $from |
|
84 | + */ |
|
67 | 85 | static public function deleteFrom($context, $from) |
68 | 86 | { |
69 | 87 | $context->appendSql("DELETE FROM ".DB::wrap($from)); |
@@ -72,6 +90,11 @@ discard block |
||
72 | 90 | |
73 | 91 | class JoinImpl |
74 | 92 | { |
93 | + /** |
|
94 | + * @param Context $context |
|
95 | + * @param null|string $type |
|
96 | + * @param string $table |
|
97 | + */ |
|
75 | 98 | static public function join($context, $type, $table) { |
76 | 99 | $table = DB::wrap($table); |
77 | 100 | if($type){ |
@@ -84,6 +107,10 @@ discard block |
||
84 | 107 | |
85 | 108 | class JoinOnImpl |
86 | 109 | { |
110 | + /** |
|
111 | + * @param Context $context |
|
112 | + * @param string $condition |
|
113 | + */ |
|
87 | 114 | static public function on($context, $condition) { |
88 | 115 | $context->appendSql("ON $condition"); |
89 | 116 | } |
@@ -91,6 +118,9 @@ discard block |
||
91 | 118 | |
92 | 119 | class ForUpdateImpl |
93 | 120 | { |
121 | + /** |
|
122 | + * @param Context $context |
|
123 | + */ |
|
94 | 124 | static public function forUpdate($context){ |
95 | 125 | $context->appendSql("FOR UPDATE"); |
96 | 126 | } |
@@ -98,6 +128,10 @@ discard block |
||
98 | 128 | |
99 | 129 | class ForUpdateOfImpl |
100 | 130 | { |
131 | + /** |
|
132 | + * @param Context $context |
|
133 | + * @param string $column |
|
134 | + */ |
|
101 | 135 | static public function of($context, $column){ |
102 | 136 | $column = DB::wrap($column); |
103 | 137 | $context->appendSql("OF $column"); |
@@ -106,6 +140,10 @@ discard block |
||
106 | 140 | |
107 | 141 | class InsertImpl |
108 | 142 | { |
143 | + /** |
|
144 | + * @param Context $context |
|
145 | + * @param string $table |
|
146 | + */ |
|
109 | 147 | static public function insertInto($context, $table) { |
110 | 148 | $table = DB::wrap($table); |
111 | 149 | $context->appendSql("INSERT INTO $table"); |
@@ -113,6 +151,10 @@ discard block |
||
113 | 151 | } |
114 | 152 | class ReplaceImpl |
115 | 153 | { |
154 | + /** |
|
155 | + * @param Context $context |
|
156 | + * @param string $table |
|
157 | + */ |
|
116 | 158 | static public function replaceInto($context, $table) { |
117 | 159 | $table = DB::wrap($table); |
118 | 160 | $context->appendSql("REPLACE INTO $table"); |
@@ -196,6 +238,10 @@ discard block |
||
196 | 238 | |
197 | 239 | class UpdateImpl |
198 | 240 | { |
241 | + /** |
|
242 | + * @param Context $context |
|
243 | + * @param string $table |
|
244 | + */ |
|
199 | 245 | static public function update($context, $table){ |
200 | 246 | $table = DB::wrap($table); |
201 | 247 | $context->appendSql("UPDATE $table"); |
@@ -212,6 +258,9 @@ discard block |
||
212 | 258 | } |
213 | 259 | } |
214 | 260 | |
261 | + /** |
|
262 | + * @param string $expr |
|
263 | + */ |
|
215 | 264 | public function setExpr(Context $context, $expr, $args){ |
216 | 265 | if($this->first){ |
217 | 266 | $this->first = false; |
@@ -274,6 +323,11 @@ discard block |
||
274 | 323 | } |
275 | 324 | return $this; |
276 | 325 | } |
326 | + |
|
327 | + /** |
|
328 | + * @param string $column |
|
329 | + * @param string $order |
|
330 | + */ |
|
277 | 331 | public function orderBy(Context $context, $column, $order=null){ |
278 | 332 | if(is_string($column)){ |
279 | 333 | if($order === null){ |
@@ -291,12 +345,20 @@ discard block |
||
291 | 345 | |
292 | 346 | class LimitImpl |
293 | 347 | { |
348 | + /** |
|
349 | + * @param integer $size |
|
350 | + */ |
|
294 | 351 | static public function limit(Context $context, $size){ |
295 | 352 | $intSize = intval($size); |
296 | 353 | strval($intSize) == $size or \PhpBoot\abort( |
297 | 354 | new \InvalidArgumentException("invalid params for limit($size)")); |
298 | 355 | $context->appendSql("LIMIT $size"); |
299 | 356 | } |
357 | + |
|
358 | + /** |
|
359 | + * @param integer $start |
|
360 | + * @param integer $size |
|
361 | + */ |
|
300 | 362 | static public function limitWithOffset(Context $context, $start, $size){ |
301 | 363 | $intStart = intval($start); |
302 | 364 | $intSize = intval($size); |
@@ -308,6 +370,9 @@ discard block |
||
308 | 370 | |
309 | 371 | class WhereImpl{ |
310 | 372 | |
373 | + /** |
|
374 | + * @param string $str |
|
375 | + */ |
|
311 | 376 | static private function findQ($str,$offset = 0,$no=0){ |
312 | 377 | $found = strpos($str, '?', $offset); |
313 | 378 | if($no == 0 || $found === false){ |
@@ -316,6 +381,9 @@ discard block |
||
316 | 381 | return self::findQ($str, $found+1, $no-1); |
317 | 382 | } |
318 | 383 | |
384 | + /** |
|
385 | + * @param string $prefix |
|
386 | + */ |
|
319 | 387 | static public function where(Context $context, $prefix, $expr, $args){ |
320 | 388 | if(empty($expr)){ |
321 | 389 | return; |
@@ -434,6 +502,10 @@ discard block |
||
434 | 502 | |
435 | 503 | self::condition($context, $prefix, implode(' AND ', $exprs), $params); |
436 | 504 | } |
505 | + |
|
506 | + /** |
|
507 | + * @param string $expr |
|
508 | + */ |
|
437 | 509 | static public function condition(Context $context, $prefix, $expr, $args){ |
438 | 510 | if(!empty($expr)){ |
439 | 511 | $expr = "($expr)"; |
@@ -506,6 +578,10 @@ discard block |
||
506 | 578 | } |
507 | 579 | |
508 | 580 | class GroupByImpl{ |
581 | + |
|
582 | + /** |
|
583 | + * @param string $column |
|
584 | + */ |
|
509 | 585 | static public function groupBy(Context $context, $column){ |
510 | 586 | $column = DB::wrap($column); |
511 | 587 | $context->appendSql("GROUP BY $column"); |
@@ -534,7 +610,6 @@ discard block |
||
534 | 610 | /** |
535 | 611 | * |
536 | 612 | * @param Context $context |
537 | - * @param string|false $asDict return as dict or array |
|
538 | 613 | * @return false|array |
539 | 614 | * @throws DBException|\Exception |
540 | 615 | */ |
@@ -605,6 +680,9 @@ discard block |
||
605 | 680 | } |
606 | 681 | class OnDuplicateKeyUpdateImpl |
607 | 682 | { |
683 | + /** |
|
684 | + * @param Context $context |
|
685 | + */ |
|
608 | 686 | public function set($context, $column, $value){ |
609 | 687 | if(is_string($column)){ |
610 | 688 | $this->setExpr($context, $column, $value); |
@@ -613,6 +691,9 @@ discard block |
||
613 | 691 | } |
614 | 692 | } |
615 | 693 | |
694 | + /** |
|
695 | + * @param string $expr |
|
696 | + */ |
|
616 | 697 | public function setExpr($context, $expr, $args){ |
617 | 698 | $prefix = ''; |
618 | 699 | if($this->first){ |