@@ -121,6 +121,9 @@ discard block |
||
121 | 121 | } |
122 | 122 | } |
123 | 123 | |
124 | + /** |
|
125 | + * @param string $filter |
|
126 | + */ |
|
124 | 127 | public static function queryCacheSetByFilter($location_type, $filter, $record_id) { |
125 | 128 | SnCache::$queries[$location_type][$filter][$record_id] = &SnCache::getDataRefByLocationAndId($location_type, $record_id); |
126 | 129 | } |
@@ -160,14 +163,23 @@ discard block |
||
160 | 163 | return true; // Не всегда - от результата |
161 | 164 | } |
162 | 165 | |
166 | + /** |
|
167 | + * @param integer $locationType |
|
168 | + */ |
|
163 | 169 | public static function getData($locationType = LOC_NONE) { |
164 | 170 | return $locationType == LOC_NONE ? static::$data : static::$data[$locationType]; |
165 | 171 | } |
166 | 172 | |
173 | + /** |
|
174 | + * @param integer $locationType |
|
175 | + */ |
|
167 | 176 | public static function cacheUnsetElement($locationType, $recordId) { |
168 | 177 | static::$data[$locationType][$recordId] = null; |
169 | 178 | } |
170 | 179 | |
180 | + /** |
|
181 | + * @param integer $locationType |
|
182 | + */ |
|
171 | 183 | public static function isArrayLocation($locationType) { |
172 | 184 | return is_array(static::$data[$locationType]); |
173 | 185 | } |
@@ -190,6 +202,9 @@ discard block |
||
190 | 202 | } |
191 | 203 | } |
192 | 204 | |
205 | + /** |
|
206 | + * @param integer $unit_snid |
|
207 | + */ |
|
193 | 208 | public static function getUnitLocator($location_type, $location_id, $unit_snid) { |
194 | 209 | return $unit_snid ? static::$locator[LOC_UNIT][$location_type][$location_id][$unit_snid] : static::$locator[LOC_UNIT][$location_type][$location_id]; |
195 | 210 | } |
@@ -222,14 +237,23 @@ discard block |
||
222 | 237 | return static::$locks; |
223 | 238 | } |
224 | 239 | |
240 | + /** |
|
241 | + * @param string $filter |
|
242 | + */ |
|
225 | 243 | public static function getQueriesByLocationAndFilter($locationType, $filter) { |
226 | 244 | return !empty(static::$queries[$locationType][$filter]) && is_array(static::$queries[$locationType][$filter]) ? static::$queries[$locationType][$filter] : array(); |
227 | 245 | } |
228 | 246 | |
247 | + /** |
|
248 | + * @param string $filter |
|
249 | + */ |
|
229 | 250 | public static function isQueryCacheByLocationAndFilterEmpty($locationType, $filter) { |
230 | 251 | return !isset(SnCache::$queries[$locationType][$filter]) || SnCache::$queries[$locationType][$filter] === null; |
231 | 252 | } |
232 | 253 | |
254 | + /** |
|
255 | + * @param string $filter |
|
256 | + */ |
|
233 | 257 | public static function queryCacheResetByLocationAndFilter($locationType, $filter) { |
234 | 258 | SnCache::$queries[$locationType][$filter] = array(); |
235 | 259 | } |
@@ -59,7 +59,7 @@ |
||
59 | 59 | if ($hard && !empty(static::$data[$location_type])) { |
60 | 60 | // Здесь нельзя делать unset - надо записывать NULL, что бы это отразилось на зависимых записях |
61 | 61 | // TODO - replace with setNull |
62 | - array_walk(static::$data[$location_type], function (&$item) { $item = null; }); |
|
62 | + array_walk(static::$data[$location_type], function(&$item) { $item = null; }); |
|
63 | 63 | } |
64 | 64 | static::$locator[$location_type] = array(); |
65 | 65 | static::$queries[$location_type] = array(); |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | |
219 | 219 | if (!empty($error_msg)) { |
220 | 220 | // TODO - Убрать позже |
221 | - print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_transaction_check() - ' . $error_msg . '</h1>'); |
|
221 | + print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_transaction_check() - '.$error_msg.'</h1>'); |
|
222 | 222 | $backtrace = debug_backtrace(); |
223 | 223 | array_shift($backtrace); |
224 | 224 | pdump($backtrace); |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | public static function db_transaction_start($level = '') { |
232 | 232 | static::db_transaction_check(null); |
233 | 233 | |
234 | - $level ? doquery('SET TRANSACTION ISOLATION LEVEL ' . $level) : false; |
|
234 | + $level ? doquery('SET TRANSACTION ISOLATION LEVEL '.$level) : false; |
|
235 | 235 | |
236 | 236 | static::$transaction_id++; |
237 | 237 | doquery('START TRANSACTION'); |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | public static function db_lock_tables($tables) { |
296 | 296 | $tables = is_array($tables) ? $tables : array($tables => ''); |
297 | 297 | foreach ($tables as $table_name => $condition) { |
298 | - self::$db->doquery("SELECT 1 FROM {{{$table_name}}}" . ($condition ? ' WHERE ' . $condition : '')); |
|
298 | + self::$db->doquery("SELECT 1 FROM {{{$table_name}}}".($condition ? ' WHERE '.$condition : '')); |
|
299 | 299 | } |
300 | 300 | } |
301 | 301 | |
@@ -355,8 +355,8 @@ discard block |
||
355 | 355 | $query = static::db_query( |
356 | 356 | "SELECT |
357 | 357 | distinct({{{$location_info[P_TABLE_NAME]}}}.{$owner_data[P_OWNER_FIELD]}) AS parent_id |
358 | - FROM {{{$location_info[P_TABLE_NAME]}}}" . |
|
359 | - ($filter ? ' WHERE ' . $filter : '') . |
|
358 | + FROM {{{$location_info[P_TABLE_NAME]}}}". |
|
359 | + ($filter ? ' WHERE '.$filter : ''). |
|
360 | 360 | ($fetch ? ' LIMIT 1' : ''), false, true); |
361 | 361 | |
362 | 362 | while ($row = db_fetch($query)) { |
@@ -369,13 +369,13 @@ discard block |
||
369 | 369 | if ($indexes_str = implode(',', $parent_id_list)) { |
370 | 370 | $parent_id_field = static::$location_info[$owner_location_type][P_ID]; |
371 | 371 | static::db_get_record_list($owner_location_type, |
372 | - $parent_id_field . (count($parent_id_list) > 1 ? " IN ({$indexes_str})" : " = {$indexes_str}"), $fetch, true); |
|
372 | + $parent_id_field.(count($parent_id_list) > 1 ? " IN ({$indexes_str})" : " = {$indexes_str}"), $fetch, true); |
|
373 | 373 | } |
374 | 374 | } |
375 | 375 | } |
376 | 376 | |
377 | 377 | $query = static::db_query( |
378 | - "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}" . |
|
378 | + "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}". |
|
379 | 379 | (($filter = trim($filter)) ? " WHERE {$filter}" : '') |
380 | 380 | ); |
381 | 381 | while ($row = db_fetch($query)) { |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | $condition = trim($condition); |
447 | 447 | $table_name = static::$location_info[$location_type][P_TABLE_NAME]; |
448 | 448 | |
449 | - if ($result = static::db_query("UPDATE {{{$table_name}}} SET " . $set . ($condition ? ' WHERE ' . $condition : ''))) { |
|
449 | + if ($result = static::db_query("UPDATE {{{$table_name}}} SET ".$set.($condition ? ' WHERE '.$condition : ''))) { |
|
450 | 450 | |
451 | 451 | if (static::$db->db_affected_rows()) { // Обновляем данные только если ряд был затронут |
452 | 452 | // Поскольку нам неизвестно, что и как обновилось - сбрасываем кэш этого типа полностью |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | $user = self::$db->selectRow( |
608 | 608 | DBStaticUser::buildSelect() |
609 | 609 | ->field('*') |
610 | - ->where(array("`username` " . ($like ? 'LIKE' : '=') . " '{$username_safe}'")) |
|
610 | + ->where(array("`username` ".($like ? 'LIKE' : '=')." '{$username_safe}'")) |
|
611 | 611 | ->setFetchOne() |
612 | 612 | ); |
613 | 613 | |
@@ -706,7 +706,7 @@ discard block |
||
706 | 706 | } |
707 | 707 | |
708 | 708 | if (SnCache::isUnitLocatorNotSet($location_type, $location_id)) { |
709 | - $got_data = static::db_get_record_list(LOC_UNIT, "unit_location_type = {$location_type} AND unit_location_id = {$location_id} AND " . static::db_unit_time_restrictions()); |
|
709 | + $got_data = static::db_get_record_list(LOC_UNIT, "unit_location_type = {$location_type} AND unit_location_id = {$location_id} AND ".static::db_unit_time_restrictions()); |
|
710 | 710 | if (!empty($got_data) && is_array($got_data)) { |
711 | 711 | foreach ($got_data as $unit_id => $unit_data) { |
712 | 712 | SnCache::setUnitLocatorByLocationAndIDs($location_type, $location_id, $unit_data); |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | if ($que_type == QUE_RESEARCH || $planet_id === null) { |
766 | 766 | $query[] = "`que_planet_id` IS NULL"; |
767 | 767 | } elseif ($planet_id) { |
768 | - $query[] = "(`que_planet_id` = {$planet_id}" . ($que_type ? '' : ' OR que_planet_id IS NULL') . ")"; |
|
768 | + $query[] = "(`que_planet_id` = {$planet_id}".($que_type ? '' : ' OR que_planet_id IS NULL').")"; |
|
769 | 769 | } |
770 | 770 | if ($que_type) { |
771 | 771 | $query[] = "`que_type` = {$que_type}"; |
@@ -879,13 +879,13 @@ discard block |
||
879 | 879 | $condition = "`{$field_name}` = "; |
880 | 880 | $value = ''; |
881 | 881 | if ($field_data['delta']) { |
882 | - $value = "`{$field_name}`" . ($field_data['delta'] >= 0 ? '+' : '') . $field_data['delta']; |
|
882 | + $value = "`{$field_name}`".($field_data['delta'] >= 0 ? '+' : '').$field_data['delta']; |
|
883 | 883 | } elseif ($field_data['set']) { |
884 | 884 | $value = (is_string($field_data['set']) ? "'{$field_data['set']}'" : $field_data['set']); |
885 | 885 | } |
886 | 886 | |
887 | 887 | if ($value) { |
888 | - $fields[] = $condition . $value; |
|
888 | + $fields[] = $condition.$value; |
|
889 | 889 | } |
890 | 890 | } |
891 | 891 | $conditions[P_FIELDS_STR] = implode(',', $fields); |
@@ -899,9 +899,7 @@ discard block |
||
899 | 899 | // Простое условие - $field_id = $field_value |
900 | 900 | if (is_string($field_id)) { |
901 | 901 | $field_value = |
902 | - $field_value === null ? 'NULL' : |
|
903 | - (is_string($field_value) ? "'" . db_escape($field_value) . "'" : |
|
904 | - (is_bool($field_value) ? intval($field_value) : $field_value)); |
|
902 | + $field_value === null ? 'NULL' : (is_string($field_value) ? "'".db_escape($field_value)."'" : (is_bool($field_value) ? intval($field_value) : $field_value)); |
|
905 | 903 | $the_conditions[] = "`{$field_id}` = {$field_value}"; |
906 | 904 | } else { |
907 | 905 | die('Неподдерживаемый тип условия'); |
@@ -928,7 +926,7 @@ discard block |
||
928 | 926 | die('Неподдерживаемая операция в classSupernova::db_changeset_condition_compile'); |
929 | 927 | } |
930 | 928 | |
931 | - $conditions[P_QUERY_STR] = $conditions[P_ACTION_STR] . ' ' . $conditions[P_FIELDS_STR] . (' WHERE ' . $conditions[P_WHERE_STR]); |
|
929 | + $conditions[P_QUERY_STR] = $conditions[P_ACTION_STR].' '.$conditions[P_FIELDS_STR].(' WHERE '.$conditions[P_WHERE_STR]); |
|
932 | 930 | } |
933 | 931 | |
934 | 932 | public static function db_changeset_apply($db_changeset, $flush_delayed = false) { |
@@ -1026,7 +1024,7 @@ discard block |
||
1026 | 1024 | ini_get('magic_quotes_sybase') ? die('SN is incompatible with \'magic_quotes_sybase\' turned on. Disable it in php.ini or .htaccess...') : false; |
1027 | 1025 | if (@get_magic_quotes_gpc()) { |
1028 | 1026 | $gpcr = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST); |
1029 | - array_walk_recursive($gpcr, function (&$value, $key) { |
|
1027 | + array_walk_recursive($gpcr, function(&$value, $key) { |
|
1030 | 1028 | $value = stripslashes($value); |
1031 | 1029 | }); |
1032 | 1030 | } |
@@ -1040,7 +1038,7 @@ discard block |
||
1040 | 1038 | public static function init_3_load_config_file() { |
1041 | 1039 | $dbsettings = array(); |
1042 | 1040 | |
1043 | - require(SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX); |
|
1041 | + require(SN_ROOT_PHYSICAL."config".DOT_PHP_EX); |
|
1044 | 1042 | self::$cache_prefix = !empty($dbsettings['cache_prefix']) ? $dbsettings['cache_prefix'] : $dbsettings['prefix']; |
1045 | 1043 | self::$db_name = $dbsettings['name']; |
1046 | 1044 | self::$sn_secret_word = $dbsettings['secretword']; |