@@ -467,6 +467,12 @@ |
||
467 | 467 | {$StartRec}, 25;"); |
468 | 468 | } |
469 | 469 | |
470 | + /** |
|
471 | + * @param integer $message_type |
|
472 | + * @param string $from_unsafe |
|
473 | + * @param string $subject_unsafe |
|
474 | + * @param string $text_unsafe |
|
475 | + */ |
|
470 | 476 | public static function db_message_insert_all($message_type, $from_unsafe, $subject_unsafe, $text_unsafe) { |
471 | 477 | $message_type_safe = intval($message_type); |
472 | 478 | $from_safe = db_escape($from_unsafe); |
@@ -169,6 +169,11 @@ discard block |
||
169 | 169 | */ |
170 | 170 | // OK v4 |
171 | 171 | // TODO - вынести в отдельный класс |
172 | +/** |
|
173 | + * @param string $db_id_field_name |
|
174 | + * @param string $db_table_name |
|
175 | + * @param string $db_value_field_name |
|
176 | + */ |
|
172 | 177 | function db_get_set_unique_id_value($current_value_unsafe, $db_id_field_name, $db_table_name, $db_value_field_name) { |
173 | 178 | $current_value_safe = db_escape($current_value_unsafe); |
174 | 179 | $value_id = classSupernova::$db->doSelectFetch("SELECT `{$db_id_field_name}` FROM {{{$db_table_name}}} WHERE `{$db_value_field_name}` = '{$current_value_safe}' LIMIT 1 FOR UPDATE"); |
@@ -487,8 +492,8 @@ discard block |
||
487 | 492 | |
488 | 493 | |
489 | 494 | /** |
490 | - * @param $user_id |
|
491 | - * @param $change_type |
|
495 | + * @param integer $user_id |
|
496 | + * @param integer $change_type |
|
492 | 497 | * @param $dark_matter |
493 | 498 | * @param $comment_unsafe |
494 | 499 | * @param $rowUserNameUnsafe |
@@ -509,7 +514,7 @@ discard block |
||
509 | 514 | /** |
510 | 515 | * @param $user_id_safe |
511 | 516 | * |
512 | - * @return array|bool|mysqli_result|null |
|
517 | + * @return integer |
|
513 | 518 | */ |
514 | 519 | function db_referral_get_by_id($user_id_safe) { |
515 | 520 | $old_referral = classSupernova::$db->doSelectFetch("SELECT * FROM {{referrals}} WHERE `id` = {$user_id_safe} LIMIT 1 FOR UPDATE;"); |
@@ -540,9 +545,9 @@ discard block |
||
540 | 545 | |
541 | 546 | // Quests *********************************************************************************************************** |
542 | 547 | /** |
543 | - * @param $query_add_select |
|
548 | + * @param string $query_add_select |
|
544 | 549 | * @param $query_add_from |
545 | - * @param $query_add_where |
|
550 | + * @param string $query_add_where |
|
546 | 551 | * |
547 | 552 | * @return array|bool|mysqli_result|null |
548 | 553 | */ |
@@ -586,11 +591,11 @@ discard block |
||
586 | 591 | } |
587 | 592 | |
588 | 593 | /** |
589 | - * @param $quest_name_unsafe |
|
590 | - * @param $quest_type |
|
591 | - * @param $quest_description_unsafe |
|
594 | + * @param string $quest_name_unsafe |
|
595 | + * @param integer $quest_type |
|
596 | + * @param string $quest_description_unsafe |
|
592 | 597 | * @param $quest_conditions |
593 | - * @param $quest_rewards |
|
598 | + * @param string $quest_rewards |
|
594 | 599 | * @param $quest_id |
595 | 600 | */ |
596 | 601 | function db_quest_update($quest_name_unsafe, $quest_type, $quest_description_unsafe, $quest_conditions, $quest_rewards, $quest_id) { |
@@ -674,7 +679,7 @@ discard block |
||
674 | 679 | |
675 | 680 | /** |
676 | 681 | * @param $payment_id |
677 | - * @param $payment_status |
|
682 | + * @param integer $payment_status |
|
678 | 683 | * @param $comment_unsafe |
679 | 684 | */ |
680 | 685 | function db_payment_update($payment_id, $payment_status, $comment_unsafe) { |
@@ -118,6 +118,9 @@ |
||
118 | 118 | return classSupernova::$gc->cacheOperator->db_ins_record(LOC_UNIT, $set); |
119 | 119 | } |
120 | 120 | |
121 | + /** |
|
122 | + * @param integer $unit_location_type |
|
123 | + */ |
|
121 | 124 | public static function db_unit_list_delete($user_id = 0, $unit_location_type, $unit_location_id = 0, $unit_snid = 0) { |
122 | 125 | $where = array('unit_location_type' => $unit_location_type); |
123 | 126 | ($unit_location_id = idval($unit_location_id)) ? $where['unit_location_id'] = $unit_location_id : false; |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | /** |
13 | 13 | * @param $adjust |
14 | - * @param $location |
|
14 | + * @param integer $location |
|
15 | 15 | * @param $object_id |
16 | 16 | */ |
17 | 17 | function db_change_units_perform($adjust, $location, $object_id) { |
@@ -32,7 +32,6 @@ discard block |
||
32 | 32 | * @param $user |
33 | 33 | * @param $planet |
34 | 34 | * @param array $unit_list |
35 | - * @param null $query |
|
36 | 35 | */ |
37 | 36 | function db_change_units(&$user, &$planet, $unit_list) { |
38 | 37 | $query = array( |
@@ -74,6 +73,9 @@ discard block |
||
74 | 73 | db_change_units_perform($query[LOC_USER], LOC_USER, $user['id']); |
75 | 74 | db_change_units_perform($query[LOC_PLANET], LOC_PLANET, $planet['id']); |
76 | 75 | } |
76 | +/** |
|
77 | + * @param string $table |
|
78 | + */ |
|
77 | 79 | function sn_db_perform($table, $values, $type = 'insert', $options = false) { |
78 | 80 | $field_set = ''; |
79 | 81 | |
@@ -163,6 +165,9 @@ discard block |
||
163 | 165 | |
164 | 166 | |
165 | 167 | |
168 | +/** |
|
169 | + * @param boolean $transaction_should_be_started |
|
170 | + */ |
|
166 | 171 | function sn_db_transaction_check($transaction_should_be_started = null) { |
167 | 172 | return classSupernova::$gc->db->getTransaction()->check($transaction_should_be_started); |
168 | 173 | } |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | /** |
158 | 158 | * @param string $query |
159 | 159 | * |
160 | - * @return mixed|string |
|
160 | + * @return string |
|
161 | 161 | */ |
162 | 162 | public function replaceTablePlaceholders($query) { |
163 | 163 | $sql = $query; |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
174 | - * @param $query |
|
174 | + * @param string $query |
|
175 | 175 | */ |
176 | 176 | protected function logQuery($query) { |
177 | 177 | if (!classSupernova::$config->debug) { |
@@ -301,6 +301,11 @@ discard block |
||
301 | 301 | |
302 | 302 | |
303 | 303 | // INSERT/REPLACE |
304 | + |
|
305 | + /** |
|
306 | + * @param string $table |
|
307 | + * @param integer $replace |
|
308 | + */ |
|
304 | 309 | protected function doSet($table, $fieldsAndValues, $replace = DB_INSERT_PLAIN) { |
305 | 310 | $query = DbQuery::build($this) |
306 | 311 | ->setTable($table) |
@@ -338,6 +343,10 @@ discard block |
||
338 | 343 | |
339 | 344 | |
340 | 345 | // INSERTERS |
346 | + |
|
347 | + /** |
|
348 | + * @param string $query |
|
349 | + */ |
|
341 | 350 | public function doInsertComplex($query) { |
342 | 351 | return $this->doSql($query); |
343 | 352 | } |
@@ -358,7 +367,7 @@ discard block |
||
358 | 367 | * Values should be passed as-is |
359 | 368 | * |
360 | 369 | * @param string $table |
361 | - * @param array $fields |
|
370 | + * @param string[] $fields |
|
362 | 371 | * @param string[] $values |
363 | 372 | * |
364 | 373 | * @return array|bool|mysqli_result|null |
@@ -415,7 +424,7 @@ discard block |
||
415 | 424 | * Self-contained - means no params used |
416 | 425 | * Such queries usually used to make large amount of in-base calculations |
417 | 426 | * |
418 | - * @param $query |
|
427 | + * @param string $query |
|
419 | 428 | * |
420 | 429 | * @return array|bool|mysqli_result|null |
421 | 430 | */ |
@@ -423,6 +432,9 @@ discard block |
||
423 | 432 | return $this->doSql($query); |
424 | 433 | } |
425 | 434 | |
435 | + /** |
|
436 | + * @param boolean $isOneRecord |
|
437 | + */ |
|
426 | 438 | protected function doUpdateWhere($table, $fieldsSet, $fieldsAdjust = array(), $where = array(), $isOneRecord = DB_RECORDS_ALL) { |
427 | 439 | // $query = DbQuery::build($this) |
428 | 440 | // ->setTable($table) |
@@ -457,10 +469,16 @@ discard block |
||
457 | 469 | return $this->doSql($query); |
458 | 470 | } |
459 | 471 | |
472 | + /** |
|
473 | + * @param string $table |
|
474 | + */ |
|
460 | 475 | public function doUpdateRowSet($table, $fieldsAndValues, $where) { |
461 | 476 | return $this->doUpdateWhere($table, $fieldsAndValues, array(), $where, DB_RECORD_ONE); |
462 | 477 | } |
463 | 478 | |
479 | + /** |
|
480 | + * @param string $table |
|
481 | + */ |
|
464 | 482 | public function doUpdateTableSet($table, $fieldsAndValues, $where = array()) { |
465 | 483 | return $this->doUpdateWhere($table, $fieldsAndValues, array(), $where, DB_RECORDS_ALL); |
466 | 484 | } |
@@ -680,6 +698,10 @@ discard block |
||
680 | 698 | } |
681 | 699 | |
682 | 700 | // TODO Заменить это на новый логгер |
701 | + |
|
702 | + /** |
|
703 | + * @param string $query |
|
704 | + */ |
|
683 | 705 | protected function security_watch_user_queries($query) { |
684 | 706 | global $user; |
685 | 707 | |
@@ -703,6 +725,9 @@ discard block |
||
703 | 725 | } |
704 | 726 | |
705 | 727 | |
728 | + /** |
|
729 | + * @param string $query |
|
730 | + */ |
|
706 | 731 | public function security_query_check_bad_words($query) { |
707 | 732 | if ($this->skipQueryCheck) { |
708 | 733 | return; |