@@ -49,7 +49,7 @@ |
||
49 | 49 | |
50 | 50 | /** |
51 | 51 | * 获取数组的类型 |
52 | - * @param $type |
|
52 | + * @param string|null $type |
|
53 | 53 | * @return string|null |
54 | 54 | */ |
55 | 55 | static function getArrayType($type){ |
@@ -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"); |
@@ -119,6 +160,9 @@ discard block |
||
119 | 160 | } |
120 | 161 | class ValuesImpl |
121 | 162 | { |
163 | + /** |
|
164 | + * @param Context $context |
|
165 | + */ |
|
122 | 166 | static public function values($context, $values){ |
123 | 167 | $params = []; |
124 | 168 | $stubs = []; |
@@ -148,6 +192,10 @@ discard block |
||
148 | 192 | |
149 | 193 | class UpdateImpl |
150 | 194 | { |
195 | + /** |
|
196 | + * @param Context $context |
|
197 | + * @param string $table |
|
198 | + */ |
|
151 | 199 | static public function update($context, $table){ |
152 | 200 | $table = DB::wrap($table); |
153 | 201 | $context->appendSql("UPDATE $table"); |
@@ -164,6 +212,9 @@ discard block |
||
164 | 212 | } |
165 | 213 | } |
166 | 214 | |
215 | + /** |
|
216 | + * @param string $expr |
|
217 | + */ |
|
167 | 218 | public function setExpr(Context $context, $expr, $args){ |
168 | 219 | if($this->first){ |
169 | 220 | $this->first = false; |
@@ -226,6 +277,11 @@ discard block |
||
226 | 277 | } |
227 | 278 | return $this; |
228 | 279 | } |
280 | + |
|
281 | + /** |
|
282 | + * @param string $column |
|
283 | + * @param string $order |
|
284 | + */ |
|
229 | 285 | public function orderBy(Context $context, $column, $order=null){ |
230 | 286 | if(is_string($column)){ |
231 | 287 | if($order === null){ |
@@ -243,12 +299,20 @@ discard block |
||
243 | 299 | |
244 | 300 | class LimitImpl |
245 | 301 | { |
302 | + /** |
|
303 | + * @param integer $size |
|
304 | + */ |
|
246 | 305 | static public function limit(Context $context, $size){ |
247 | 306 | $intSize = intval($size); |
248 | 307 | strval($intSize) == $size or \PhpBoot\abort( |
249 | 308 | new \InvalidArgumentException("invalid params for limit($size)")); |
250 | 309 | $context->appendSql("LIMIT $size"); |
251 | 310 | } |
311 | + |
|
312 | + /** |
|
313 | + * @param integer $start |
|
314 | + * @param integer $size |
|
315 | + */ |
|
252 | 316 | static public function limitWithOffset(Context $context, $start, $size){ |
253 | 317 | $intStart = intval($start); |
254 | 318 | $intSize = intval($size); |
@@ -260,6 +324,9 @@ discard block |
||
260 | 324 | |
261 | 325 | class WhereImpl{ |
262 | 326 | |
327 | + /** |
|
328 | + * @param string $str |
|
329 | + */ |
|
263 | 330 | static private function findQ($str,$offset = 0,$no=0){ |
264 | 331 | $found = strpos($str, '?', $offset); |
265 | 332 | if($no == 0 || $found === false){ |
@@ -307,6 +374,7 @@ discard block |
||
307 | 374 | * LIKE 'id'=>['LIKE' => '1%'] |
308 | 375 | * IN 'id'=>['IN' => [1,2,3]] |
309 | 376 | * NOT IN 'id'=>['NOT IN' => [1,2,3]] |
377 | + * @param string $prefix |
|
310 | 378 | * @return void |
311 | 379 | */ |
312 | 380 | static public function conditionArgs(Context $context, $prefix, $args=[]){ |
@@ -374,6 +442,10 @@ discard block |
||
374 | 442 | |
375 | 443 | self::condition($context, $prefix, implode(' AND ', $exprs), $params); |
376 | 444 | } |
445 | + |
|
446 | + /** |
|
447 | + * @param string $expr |
|
448 | + */ |
|
377 | 449 | static public function condition(Context $context, $prefix, $expr, $args){ |
378 | 450 | if(!empty($expr)){ |
379 | 451 | if($args){ |
@@ -436,6 +508,10 @@ discard block |
||
436 | 508 | } |
437 | 509 | |
438 | 510 | class GroupByImpl{ |
511 | + |
|
512 | + /** |
|
513 | + * @param string $column |
|
514 | + */ |
|
439 | 515 | static public function groupBy(Context $context, $column){ |
440 | 516 | $column = DB::wrap($column); |
441 | 517 | $context->appendSql("GROUP BY $column"); |
@@ -458,7 +534,6 @@ discard block |
||
458 | 534 | /** |
459 | 535 | * |
460 | 536 | * @param Context $context |
461 | - * @param string|false $asDict return as dict or array |
|
462 | 537 | * @return false|array |
463 | 538 | */ |
464 | 539 | static public function get($context, $dictAs=false){ |
@@ -517,6 +592,9 @@ discard block |
||
517 | 592 | } |
518 | 593 | class OnDuplicateKeyUpdateImpl |
519 | 594 | { |
595 | + /** |
|
596 | + * @param Context $context |
|
597 | + */ |
|
520 | 598 | public function set($context, $column, $value){ |
521 | 599 | if(is_string($column)){ |
522 | 600 | $this->setExpr($context, $column, $value); |
@@ -525,6 +603,9 @@ discard block |
||
525 | 603 | } |
526 | 604 | } |
527 | 605 | |
606 | + /** |
|
607 | + * @param string $expr |
|
608 | + */ |
|
528 | 609 | public function setExpr($context, $expr, $args){ |
529 | 610 | $prefix = ''; |
530 | 611 | if($this->first){ |
@@ -41,6 +41,9 @@ discard block |
||
41 | 41 | |
42 | 42 | class OnDuplicateKeyUpdateRule extends ExecRule |
43 | 43 | { |
44 | + /** |
|
45 | + * @param \PhpBoot\DB\Context $context |
|
46 | + */ |
|
44 | 47 | public function __construct($context) |
45 | 48 | { |
46 | 49 | parent::__construct($context); |
@@ -91,8 +94,6 @@ discard block |
||
91 | 94 | * ->onDuplicateKeyUpdate('a=a+1') |
92 | 95 | * => "INSERT INTO table(a,b) VALUES(1,now()) ON DUPLICATE KEY UPDATE a=a+1" |
93 | 96 | * |
94 | - * @param string $column |
|
95 | - * @param mixed $value |
|
96 | 97 | * @return \PhpBoot\DB\rules\basic\ExecRule |
97 | 98 | */ |
98 | 99 | public function onDuplicateKeyUpdate($expr, $_=null) { |
@@ -111,6 +111,9 @@ discard block |
||
111 | 111 | |
112 | 112 | class OrderByRule extends LimitRule |
113 | 113 | { |
114 | + /** |
|
115 | + * @param \PhpBoot\DB\Context $context |
|
116 | + */ |
|
114 | 117 | public function __construct($context){ |
115 | 118 | parent::__construct($context); |
116 | 119 | $this->order = new OrderByImpl(); |
@@ -211,7 +214,7 @@ discard block |
||
211 | 214 | * "WHERE a=1 AND b IN(1,2) AND c BETWEEN 1 AND 2 AND d<>1" |
212 | 215 | * @param string|array $conditions |
213 | 216 | * //TODO where(callable $query) |
214 | - * @param mixed $_ |
|
217 | + * @param string $_ |
|
215 | 218 | * @return \PhpBoot\DB\rules\select\GroupByRule |
216 | 219 | */ |
217 | 220 | public function where($conditions=null, $_=null) { |
@@ -49,7 +49,6 @@ |
||
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\OrderByRule |
55 | 54 | */ |