@@ -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) { |
@@ -286,6 +286,7 @@ discard block |
||
| 286 | 286 | * @param array $fields |
| 287 | 287 | * @param array $where |
| 288 | 288 | * @param bool $isOneRecord |
| 289 | + * @param boolean $forUpdate |
|
| 289 | 290 | * |
| 290 | 291 | * @return array|bool|mysqli_result|null |
| 291 | 292 | */ |
@@ -331,6 +332,11 @@ discard block |
||
| 331 | 332 | |
| 332 | 333 | |
| 333 | 334 | // INSERT/REPLACE |
| 335 | + |
|
| 336 | + /** |
|
| 337 | + * @param string $table |
|
| 338 | + * @param integer $replace |
|
| 339 | + */ |
|
| 334 | 340 | protected function doSet($table, $fieldsAndValues, $replace = DB_INSERT_PLAIN) { |
| 335 | 341 | $query = DbQuery::build($this) |
| 336 | 342 | ->setTable($table) |
@@ -368,6 +374,10 @@ discard block |
||
| 368 | 374 | |
| 369 | 375 | |
| 370 | 376 | // INSERTERS |
| 377 | + |
|
| 378 | + /** |
|
| 379 | + * @param string $query |
|
| 380 | + */ |
|
| 371 | 381 | public function doInsertComplex($query) { |
| 372 | 382 | return $this->doSql($query); |
| 373 | 383 | } |
@@ -387,7 +397,7 @@ discard block |
||
| 387 | 397 | * Values should be passed as-is |
| 388 | 398 | * |
| 389 | 399 | * @param string $table |
| 390 | - * @param array $fields |
|
| 400 | + * @param string[] $fields |
|
| 391 | 401 | * @param string[] $values |
| 392 | 402 | * |
| 393 | 403 | * @return array|bool|mysqli_result|null |
@@ -440,7 +450,7 @@ discard block |
||
| 440 | 450 | * Self-contained - means no params used |
| 441 | 451 | * Such queries usually used to make large amount of in-base calculations |
| 442 | 452 | * |
| 443 | - * @param $query |
|
| 453 | + * @param string $query |
|
| 444 | 454 | * |
| 445 | 455 | * @return array|bool|mysqli_result|null |
| 446 | 456 | */ |
@@ -457,13 +467,16 @@ discard block |
||
| 457 | 467 | } |
| 458 | 468 | |
| 459 | 469 | /** |
| 460 | - * @param $DbQuery DbQuery |
|
| 470 | + * @param DbQuery $DbQuery DbQuery |
|
| 461 | 471 | */ |
| 462 | 472 | public function doUpdateDbQueryAdjust($DbQuery) { |
| 463 | 473 | return $this->doUpdateDbQuery($DbQuery); |
| 464 | 474 | } |
| 465 | 475 | |
| 466 | 476 | |
| 477 | + /** |
|
| 478 | + * @param boolean $isOneRecord |
|
| 479 | + */ |
|
| 467 | 480 | protected function doUpdateWhere($table, $fieldsSet, $fieldsAdjust = array(), $where = array(), $isOneRecord = DB_RECORDS_ALL, $whereDanger = array()) { |
| 468 | 481 | $query = DbQuery::build($this) |
| 469 | 482 | ->setTable($table) |
@@ -482,6 +495,9 @@ discard block |
||
| 482 | 495 | return $this->doUpdateWhere($table, $fieldsAndValues, array(), $where, DB_RECORD_ONE); |
| 483 | 496 | } |
| 484 | 497 | |
| 498 | + /** |
|
| 499 | + * @param string $table |
|
| 500 | + */ |
|
| 485 | 501 | public function doUpdateTableSet($table, $fieldsAndValues, $where = array()) { |
| 486 | 502 | return $this->doUpdateWhere($table, $fieldsAndValues, array(), $where, DB_RECORDS_ALL); |
| 487 | 503 | } |
@@ -597,6 +613,10 @@ discard block |
||
| 597 | 613 | } |
| 598 | 614 | |
| 599 | 615 | // TODO Заменить это на новый логгер |
| 616 | + |
|
| 617 | + /** |
|
| 618 | + * @param string $query |
|
| 619 | + */ |
|
| 600 | 620 | protected function security_watch_user_queries($query) { |
| 601 | 621 | global $user; |
| 602 | 622 | |
@@ -620,6 +640,9 @@ discard block |
||
| 620 | 640 | } |
| 621 | 641 | |
| 622 | 642 | |
| 643 | + /** |
|
| 644 | + * @param string $query |
|
| 645 | + */ |
|
| 623 | 646 | public function security_query_check_bad_words($query) { |
| 624 | 647 | if ($this->skipQueryCheck) { |
| 625 | 648 | return; |
@@ -85,6 +85,9 @@ |
||
| 85 | 85 | return $this->db->doSelectIterator($query); |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | + /** |
|
| 89 | + * @param string $table |
|
| 90 | + */ |
|
| 88 | 91 | public function doUpdateRowSetAffected($table, $fieldsAndValues, $where) { |
| 89 | 92 | $this->db->doUpdateRowSet($table, $fieldsAndValues, $where); |
| 90 | 93 | return $this->db->db_affected_rows(); |
@@ -67,7 +67,7 @@ |
||
| 67 | 67 | if (is_callable($callable)) { |
| 68 | 68 | $this->accessors[$varName][$type] = $callable; |
| 69 | 69 | } else { |
| 70 | - throw new \Exception('Error assigning callable in ' . get_called_class() . '! Callable typed [' . $type . '] is not a callable or not accessible in the scope'); |
|
| 70 | + throw new \Exception('Error assigning callable in '.get_called_class().'! Callable typed ['.$type.'] is not a callable or not accessible in the scope'); |
|
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | |
@@ -34,56 +34,56 @@ |
||
| 34 | 34 | $gc = $this; |
| 35 | 35 | |
| 36 | 36 | // Default db |
| 37 | - $gc->db = function ($c) { |
|
| 37 | + $gc->db = function($c) { |
|
| 38 | 38 | classSupernova::$db = $db = new \db_mysql($c); |
| 39 | 39 | $db->sn_db_connect(); |
| 40 | 40 | |
| 41 | 41 | return $db; |
| 42 | 42 | }; |
| 43 | 43 | |
| 44 | - $gc->debug = function ($c) { |
|
| 44 | + $gc->debug = function($c) { |
|
| 45 | 45 | return new \debug(); |
| 46 | 46 | }; |
| 47 | 47 | |
| 48 | - $gc->types = function ($c) { |
|
| 48 | + $gc->types = function($c) { |
|
| 49 | 49 | return new \Common\Types(); |
| 50 | 50 | }; |
| 51 | 51 | |
| 52 | - $gc->cache = function ($c) { |
|
| 52 | + $gc->cache = function($c) { |
|
| 53 | 53 | return new \classCache(classSupernova::$cache_prefix); |
| 54 | 54 | }; |
| 55 | 55 | |
| 56 | - $gc->config = function ($c) { |
|
| 56 | + $gc->config = function($c) { |
|
| 57 | 57 | return new \classConfig(classSupernova::$cache_prefix); |
| 58 | 58 | }; |
| 59 | 59 | |
| 60 | - $gc->localePlayer = function (GlobalContainer $c) { |
|
| 60 | + $gc->localePlayer = function(GlobalContainer $c) { |
|
| 61 | 61 | return new \classLocale($c->config->server_locale_log_usage); |
| 62 | 62 | }; |
| 63 | 63 | |
| 64 | - $gc->dbGlobalRowOperator = function (GlobalContainer $c) { |
|
| 64 | + $gc->dbGlobalRowOperator = function(GlobalContainer $c) { |
|
| 65 | 65 | return new \DbRowDirectOperator($c->db); |
| 66 | 66 | }; |
| 67 | 67 | |
| 68 | - $gc->query = $gc->factory(function (GlobalContainer $c) { |
|
| 68 | + $gc->query = $gc->factory(function(GlobalContainer $c) { |
|
| 69 | 69 | return new \DbQueryConstructor($c->db); |
| 70 | 70 | }); |
| 71 | 71 | |
| 72 | - $gc->cacheOperator = function (GlobalContainer $gc) { |
|
| 72 | + $gc->cacheOperator = function(GlobalContainer $gc) { |
|
| 73 | 73 | return new \SnDbCachedOperator($gc); |
| 74 | 74 | }; |
| 75 | 75 | |
| 76 | 76 | $gc->snCacheClass = 'SnCache'; |
| 77 | - $gc->snCache = function (GlobalContainer $gc) { |
|
| 77 | + $gc->snCache = function(GlobalContainer $gc) { |
|
| 78 | 78 | return $gc->db->snCache; |
| 79 | 79 | }; |
| 80 | 80 | |
| 81 | 81 | $gc->buddyClass = 'Buddy\BuddyModel'; |
| 82 | - $gc->buddyModel = function (GlobalContainer $c) { |
|
| 82 | + $gc->buddyModel = function(GlobalContainer $c) { |
|
| 83 | 83 | return new $c->buddyClass($c); |
| 84 | 84 | }; |
| 85 | 85 | |
| 86 | - $gc->unitModel = function (GlobalContainer $c) { |
|
| 86 | + $gc->unitModel = function(GlobalContainer $c) { |
|
| 87 | 87 | return new \V2Unit\V2UnitModel($c); |
| 88 | 88 | }; |
| 89 | 89 | } |