|
@@ -236,7 +236,7 @@ discard block |
|
|
block discarded – undo |
|
236
|
236
|
public static function cache_clear($location_type, $hard = true) { |
|
237
|
237
|
if ($hard && !empty(static::$data[$location_type])) { |
|
238
|
238
|
// Здесь нельзя делать unset - надо записывать NULL, что бы это отразилось на зависимых записях |
|
239
|
|
- array_walk(static::$data[$location_type], function (&$item) { $item = null; }); |
|
|
239
|
+ array_walk(static::$data[$location_type], function(&$item) { $item = null; }); |
|
240
|
240
|
} |
|
241
|
241
|
static::$locator[$location_type] = array(); |
|
242
|
242
|
static::$queries[$location_type] = array(); |
|
@@ -354,7 +354,7 @@ discard block |
|
|
block discarded – undo |
|
354
|
354
|
|
|
355
|
355
|
if (!empty($error_msg)) { |
|
356
|
356
|
// TODO - Убрать позже |
|
357
|
|
- print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_transaction_check() - ' . $error_msg . '</h1>'); |
|
|
357
|
+ print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_transaction_check() - '.$error_msg.'</h1>'); |
|
358
|
358
|
$backtrace = debug_backtrace(); |
|
359
|
359
|
array_shift($backtrace); |
|
360
|
360
|
pdump($backtrace); |
|
@@ -367,7 +367,7 @@ discard block |
|
|
block discarded – undo |
|
367
|
367
|
public static function db_transaction_start($level = '') { |
|
368
|
368
|
static::db_transaction_check(null); |
|
369
|
369
|
|
|
370
|
|
- $level ? doquery('SET TRANSACTION ISOLATION LEVEL ' . $level) : false; |
|
|
370
|
+ $level ? doquery('SET TRANSACTION ISOLATION LEVEL '.$level) : false; |
|
371
|
371
|
|
|
372
|
372
|
static::$transaction_id++; |
|
373
|
373
|
doquery('START TRANSACTION'); |
|
@@ -427,7 +427,7 @@ discard block |
|
|
block discarded – undo |
|
427
|
427
|
public static function db_lock_tables($tables) { |
|
428
|
428
|
$tables = is_array($tables) ? $tables : array($tables => ''); |
|
429
|
429
|
foreach ($tables as $table_name => $condition) { |
|
430
|
|
- self::$db->doquery("SELECT 1 FROM {{{$table_name}}}" . ($condition ? ' WHERE ' . $condition : '')); |
|
|
430
|
+ self::$db->doquery("SELECT 1 FROM {{{$table_name}}}".($condition ? ' WHERE '.$condition : '')); |
|
431
|
431
|
} |
|
432
|
432
|
} |
|
433
|
433
|
|
|
@@ -481,8 +481,8 @@ discard block |
|
|
block discarded – undo |
|
481
|
481
|
$query = static::db_query( |
|
482
|
482
|
"SELECT |
|
483
|
483
|
distinct({{{$location_info[P_TABLE_NAME]}}}.{$owner_data[P_OWNER_FIELD]}) AS parent_id |
|
484
|
|
- FROM {{{$location_info[P_TABLE_NAME]}}}" . |
|
485
|
|
- ($filter ? ' WHERE ' . $filter : '') . |
|
|
484
|
+ FROM {{{$location_info[P_TABLE_NAME]}}}". |
|
|
485
|
+ ($filter ? ' WHERE '.$filter : ''). |
|
486
|
486
|
($fetch ? ' LIMIT 1' : ''), false, true); |
|
487
|
487
|
|
|
488
|
488
|
while ($row = db_fetch($query)) { |
|
@@ -495,13 +495,13 @@ discard block |
|
|
block discarded – undo |
|
495
|
495
|
if ($indexes_str = implode(',', $parent_id_list)) { |
|
496
|
496
|
$parent_id_field = static::$location_info[$owner_location_type][P_ID]; |
|
497
|
497
|
static::db_get_record_list($owner_location_type, |
|
498
|
|
- $parent_id_field . (count($parent_id_list) > 1 ? " IN ({$indexes_str})" : " = {$indexes_str}"), $fetch, true); |
|
|
498
|
+ $parent_id_field.(count($parent_id_list) > 1 ? " IN ({$indexes_str})" : " = {$indexes_str}"), $fetch, true); |
|
499
|
499
|
} |
|
500
|
500
|
} |
|
501
|
501
|
} |
|
502
|
502
|
|
|
503
|
503
|
$query = static::db_query( |
|
504
|
|
- "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}" . |
|
|
504
|
+ "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}". |
|
505
|
505
|
(($filter = trim($filter)) ? " WHERE {$filter}" : '') |
|
506
|
506
|
); |
|
507
|
507
|
while ($row = db_fetch($query)) { |
|
@@ -567,7 +567,7 @@ discard block |
|
|
block discarded – undo |
|
567
|
567
|
$condition = trim($condition); |
|
568
|
568
|
$table_name = static::$location_info[$location_type][P_TABLE_NAME]; |
|
569
|
569
|
|
|
570
|
|
- if ($result = static::db_query("UPDATE {{{$table_name}}} SET " . $set . ($condition ? ' WHERE ' . $condition : ''))) { |
|
|
570
|
+ if ($result = static::db_query("UPDATE {{{$table_name}}} SET ".$set.($condition ? ' WHERE '.$condition : ''))) { |
|
571
|
571
|
|
|
572
|
572
|
if (static::$db->db_affected_rows()) { // Обновляем данные только если ряд был затронут |
|
573
|
573
|
// Поскольку нам неизвестно, что и как обновилось - сбрасываем кэш этого типа полностью |
|
@@ -728,7 +728,7 @@ discard block |
|
|
block discarded – undo |
|
728
|
728
|
|
|
729
|
729
|
// TODO переписать |
|
730
|
730
|
$user = static::db_query( |
|
731
|
|
- "SELECT * FROM {{users}} WHERE `username` " . ($like ? 'LIKE' : '=') . " '{$username_safe}'" |
|
|
731
|
+ "SELECT * FROM {{users}} WHERE `username` ".($like ? 'LIKE' : '=')." '{$username_safe}'" |
|
732
|
732
|
, true); |
|
733
|
733
|
static::cache_set(LOC_USER, $user); // В кэш-юзер так же заполнять индексы |
|
734
|
734
|
} |
|
@@ -817,7 +817,7 @@ discard block |
|
|
block discarded – undo |
|
817
|
817
|
|
|
818
|
818
|
$query_cache = &static::$locator[LOC_UNIT][$location_type][$location_id]; |
|
819
|
819
|
if (!isset($query_cache)) { |
|
820
|
|
- $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()); |
|
|
820
|
+ $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()); |
|
821
|
821
|
if (is_array($got_data)) { |
|
822
|
822
|
foreach ($got_data as $unit_id => $unit_data) { |
|
823
|
823
|
$query_cache[$unit_data['unit_snid']] = &static::$data[LOC_UNIT][$unit_id]; |
|
@@ -878,7 +878,7 @@ discard block |
|
|
block discarded – undo |
|
878
|
878
|
if ($que_type == QUE_RESEARCH || $planet_id === null) { |
|
879
|
879
|
$query[] = "`que_planet_id` IS NULL"; |
|
880
|
880
|
} elseif ($planet_id) { |
|
881
|
|
- $query[] = "(`que_planet_id` = {$planet_id}" . ($que_type ? '' : ' OR que_planet_id IS NULL') . ")"; |
|
|
881
|
+ $query[] = "(`que_planet_id` = {$planet_id}".($que_type ? '' : ' OR que_planet_id IS NULL').")"; |
|
882
|
882
|
} |
|
883
|
883
|
if ($que_type) { |
|
884
|
884
|
$query[] = "`que_type` = {$que_type}"; |
|
@@ -999,13 +999,13 @@ discard block |
|
|
block discarded – undo |
|
999
|
999
|
$condition = "`{$field_name}` = "; |
|
1000
|
1000
|
$value = ''; |
|
1001
|
1001
|
if ($field_data['delta']) { |
|
1002
|
|
- $value = "`{$field_name}`" . ($field_data['delta'] >= 0 ? '+' : '') . $field_data['delta']; |
|
|
1002
|
+ $value = "`{$field_name}`".($field_data['delta'] >= 0 ? '+' : '').$field_data['delta']; |
|
1003
|
1003
|
} elseif ($field_data['set']) { |
|
1004
|
1004
|
$value = (is_string($field_data['set']) ? "'{$field_data['set']}'" : $field_data['set']); |
|
1005
|
1005
|
} |
|
1006
|
1006
|
|
|
1007
|
1007
|
if ($value) { |
|
1008
|
|
- $fields[] = $condition . $value; |
|
|
1008
|
+ $fields[] = $condition.$value; |
|
1009
|
1009
|
} |
|
1010
|
1010
|
} |
|
1011
|
1011
|
$conditions[P_FIELDS_STR] = implode(',', $fields); |
|
@@ -1019,9 +1019,7 @@ discard block |
|
|
block discarded – undo |
|
1019
|
1019
|
// Простое условие - $field_id = $field_value |
|
1020
|
1020
|
if (is_string($field_id)) { |
|
1021
|
1021
|
$field_value = |
|
1022
|
|
- $field_value === null ? 'NULL' : |
|
1023
|
|
- (is_string($field_value) ? "'" . db_escape($field_value) . "'" : |
|
1024
|
|
- (is_bool($field_value) ? intval($field_value) : $field_value)); |
|
|
1022
|
+ $field_value === null ? 'NULL' : (is_string($field_value) ? "'".db_escape($field_value)."'" : (is_bool($field_value) ? intval($field_value) : $field_value)); |
|
1025
|
1023
|
$the_conditions[] = "`{$field_id}` = {$field_value}"; |
|
1026
|
1024
|
} else { |
|
1027
|
1025
|
die('Неподдерживаемый тип условия'); |
|
@@ -1048,7 +1046,7 @@ discard block |
|
|
block discarded – undo |
|
1048
|
1046
|
die('Неподдерживаемая операция в classSupernova::db_changeset_condition_compile'); |
|
1049
|
1047
|
} |
|
1050
|
1048
|
|
|
1051
|
|
- $conditions[P_QUERY_STR] = $conditions[P_ACTION_STR] . ' ' . $conditions[P_FIELDS_STR] . (' WHERE ' . $conditions[P_WHERE_STR]); |
|
|
1049
|
+ $conditions[P_QUERY_STR] = $conditions[P_ACTION_STR].' '.$conditions[P_FIELDS_STR].(' WHERE '.$conditions[P_WHERE_STR]); |
|
1052
|
1050
|
} |
|
1053
|
1051
|
|
|
1054
|
1052
|
public static function db_changeset_apply($db_changeset, $flush_delayed = false) { |
|
@@ -1146,7 +1144,7 @@ discard block |
|
|
block discarded – undo |
|
1146
|
1144
|
ini_get('magic_quotes_sybase') ? die('SN is incompatible with \'magic_quotes_sybase\' turned on. Disable it in php.ini or .htaccess...') : false; |
|
1147
|
1145
|
if (@get_magic_quotes_gpc()) { |
|
1148
|
1146
|
$gpcr = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST); |
|
1149
|
|
- array_walk_recursive($gpcr, function (&$value, $key) { |
|
|
1147
|
+ array_walk_recursive($gpcr, function(&$value, $key) { |
|
1150
|
1148
|
$value = stripslashes($value); |
|
1151
|
1149
|
}); |
|
1152
|
1150
|
} |
|
@@ -1160,7 +1158,7 @@ discard block |
|
|
block discarded – undo |
|
1160
|
1158
|
public static function init_3_load_config_file() { |
|
1161
|
1159
|
$dbsettings = array(); |
|
1162
|
1160
|
|
|
1163
|
|
- require(SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX); |
|
|
1161
|
+ require(SN_ROOT_PHYSICAL."config".DOT_PHP_EX); |
|
1164
|
1162
|
self::$cache_prefix = !empty($dbsettings['cache_prefix']) ? $dbsettings['cache_prefix'] : $dbsettings['prefix']; |
|
1165
|
1163
|
self::$db_name = $dbsettings['name']; |
|
1166
|
1164
|
self::$sn_secret_word = $dbsettings['secretword']; |