@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | } |
25 | 25 | |
26 | 26 | if (SnCache::isUnitLocatorNotSet($location_type, $location_id)) { |
27 | - $got_data = classSupernova::$gc->cacheOperator->db_get_record_list(LOC_UNIT, "unit_location_type = {$location_type} AND unit_location_id = {$location_id} AND " . DBStaticUnit::db_unit_time_restrictions()); |
|
27 | + $got_data = classSupernova::$gc->cacheOperator->db_get_record_list(LOC_UNIT, "unit_location_type = {$location_type} AND unit_location_id = {$location_id} AND ".DBStaticUnit::db_unit_time_restrictions()); |
|
28 | 28 | if (!empty($got_data) && is_array($got_data)) { |
29 | 29 | foreach ($got_data as $unit_id => $unit_data) { |
30 | 30 | SnCache::setUnitLocatorByLocationAndIDs($location_type, $location_id, $unit_data); |
@@ -59,9 +59,9 @@ discard block |
||
59 | 59 | |
60 | 60 | public static function db_unit_count_by_user_and_type_and_snid($user_id, $unit_type = 0, $unit_snid = 0) { |
61 | 61 | $query = classSupernova::$db->doSelect( |
62 | - "SELECT unit_snid, sum(unit_level) as `qty` FROM {{unit}} WHERE `unit_player_id` = {$user_id} " . |
|
63 | - ($unit_type ? "AND `unit_type` = {$unit_type} " : '') . |
|
64 | - ($unit_snid ? "AND `unit_snid` = {$unit_snid} " : '') . |
|
62 | + "SELECT unit_snid, sum(unit_level) as `qty` FROM {{unit}} WHERE `unit_player_id` = {$user_id} ". |
|
63 | + ($unit_type ? "AND `unit_type` = {$unit_type} " : ''). |
|
64 | + ($unit_snid ? "AND `unit_snid` = {$unit_snid} " : ''). |
|
65 | 65 | 'GROUP BY `unit_snid`' |
66 | 66 | ); |
67 | 67 | $result = array(); |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | WHERE |
82 | 82 | f.fleet_owner = {$user_id} AND |
83 | 83 | (f.fleet_start_planet_id = {$location_id} OR f.fleet_end_planet_id = {$location_id}) |
84 | - AND u.unit_snid = {$unit_snid} AND u.`unit_location_type` = " . LOC_FLEET . " AND " . self::db_unit_time_restrictions() . |
|
85 | - " LIMIT 1" . |
|
84 | + AND u.unit_snid = {$unit_snid} AND u.`unit_location_type` = ".LOC_FLEET." AND ".self::db_unit_time_restrictions(). |
|
85 | + " LIMIT 1". |
|
86 | 86 | ($for_update ? ' FOR UPDATE' : '')); |
87 | 87 | } |
88 | 88 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | public static function db_unit_list_laboratories($user_id) { |
91 | 91 | return classSupernova::$db->doSelect("SELECT DISTINCT unit_location_id AS `id` |
92 | 92 | FROM {{unit}} |
93 | - WHERE unit_player_id = {$user_id} AND unit_location_type = " . LOC_PLANET . " AND unit_level > 0 AND unit_snid IN (" . STRUC_LABORATORY . ", " . STRUC_LABORATORY_NANO . ");"); |
|
93 | + WHERE unit_player_id = {$user_id} AND unit_location_type = ".LOC_PLANET." AND unit_level > 0 AND unit_snid IN (".STRUC_LABORATORY.", ".STRUC_LABORATORY_NANO.");"); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | public static function db_unit_set_by_id($unit_id, $set) { |
@@ -108,9 +108,9 @@ discard block |
||
108 | 108 | |
109 | 109 | public static function db_unit_list_delete($user_id = 0, $unit_location_type, $unit_location_id = 0, $unit_snid = 0) { |
110 | 110 | return classSupernova::$gc->cacheOperator->db_del_record_list(LOC_UNIT, |
111 | - "`unit_location_type` = {$unit_location_type}" . |
|
112 | - ($unit_location_id = idval($unit_location_id) ? " AND `unit_location_id` = {$unit_location_id}" : '') . |
|
113 | - ($user_id = idval($user_id) ? " AND `unit_player_id` = {$user_id}" : '') . |
|
111 | + "`unit_location_type` = {$unit_location_type}". |
|
112 | + ($unit_location_id = idval($unit_location_id) ? " AND `unit_location_id` = {$unit_location_id}" : ''). |
|
113 | + ($user_id = idval($user_id) ? " AND `unit_player_id` = {$user_id}" : ''). |
|
114 | 114 | ($unit_snid = idval($unit_snid) ? " AND `unit_snid` = {$unit_snid}" : '')); |
115 | 115 | } |
116 | 116 | |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | return classSupernova::$db->doSelect( |
119 | 119 | "SELECT unit_player_id, unit_type, unit_snid, unit_level, count(*) AS unit_amount |
120 | 120 | FROM `{{unit}}` |
121 | - WHERE unit_level > 0 AND " . self::db_unit_time_restrictions() . |
|
121 | + WHERE unit_level > 0 AND " . self::db_unit_time_restrictions(). |
|
122 | 122 | " GROUP BY unit_player_id, unit_type, unit_snid, unit_level" |
123 | 123 | ); |
124 | 124 | } |
@@ -130,15 +130,15 @@ discard block |
||
130 | 130 | |
131 | 131 | |
132 | 132 | public static function db_unit_list_admin_delete_mercenaries_finished() { |
133 | - return classSupernova::$db->doDelete("DELETE FROM `{{unit}}` WHERE unit_time_finish IS NOT NULL AND unit_time_finish < FROM_UNIXTIME(" . SN_TIME_NOW . ") AND unit_type = " . UNIT_MERCENARIES); |
|
133 | + return classSupernova::$db->doDelete("DELETE FROM `{{unit}}` WHERE unit_time_finish IS NOT NULL AND unit_time_finish < FROM_UNIXTIME(".SN_TIME_NOW.") AND unit_type = ".UNIT_MERCENARIES); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | public static function db_unit_list_admin_set_mercenaries_expire_time($default_length) { |
137 | 137 | return classSupernova::$db->doUpdate( |
138 | 138 | "UPDATE `{{unit}}` |
139 | 139 | SET |
140 | - unit_time_start = FROM_UNIXTIME(" . SN_TIME_NOW . "), |
|
141 | - unit_time_finish = FROM_UNIXTIME(" . (SN_TIME_NOW + $default_length) . ") |
|
140 | + unit_time_start = FROM_UNIXTIME(" . SN_TIME_NOW."), |
|
141 | + unit_time_finish = FROM_UNIXTIME(" . (SN_TIME_NOW + $default_length).") |
|
142 | 142 | WHERE unit_type = " . UNIT_MERCENARIES |
143 | 143 | ); |
144 | 144 | } |
@@ -163,13 +163,13 @@ discard block |
||
163 | 163 | |
164 | 164 | $temp = DBStaticUnit::db_get_unit_by_location($user['id'], $unit_location, $location_id, $unit_id, true, 'unit_id'); |
165 | 165 | if (!empty($temp['unit_id'])) { |
166 | - $result = (bool)classSupernova::$gc->cacheOperator->db_upd_record_list( |
|
166 | + $result = (bool) classSupernova::$gc->cacheOperator->db_upd_record_list( |
|
167 | 167 | LOC_UNIT, "`unit_level` = `unit_level` + ($unit_value)", "`unit_id` = {$temp['unit_id']}" |
168 | 168 | ); |
169 | 169 | } else { |
170 | 170 | $locationIdRendered = $unit_location == LOC_USER ? $user['id'] : $planet_id; |
171 | 171 | $unitType = get_unit_param($unit_id, P_UNIT_TYPE); |
172 | - $result = (bool)classSupernova::$gc->cacheOperator->db_ins_record( |
|
172 | + $result = (bool) classSupernova::$gc->cacheOperator->db_ins_record( |
|
173 | 173 | LOC_UNIT, |
174 | 174 | "unit_player_id = {$user['id']}, |
175 | 175 | unit_location_type = {$unit_location}, |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | ->where('`user_as_ally` IS NULL') |
24 | 24 | ->orderBy(array('`id` DESC')); |
25 | 25 | |
26 | - return (string)$query->selectValue(); |
|
26 | + return (string) $query->selectValue(); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -48,15 +48,15 @@ discard block |
||
48 | 48 | static::buildDBQ() |
49 | 49 | ->field('id') |
50 | 50 | ->where("`user_as_ally` IS NULL") |
51 | - ->where("`user_bot` = " . USER_BOT_PLAYER) |
|
51 | + ->where("`user_bot` = ".USER_BOT_PLAYER) |
|
52 | 52 | ->setForUpdate(); |
53 | 53 | |
54 | 54 | return $query->selectIterator(); |
55 | 55 | } |
56 | 56 | |
57 | 57 | public static function db_user_lock_with_target_owner_and_acs($user, $planet = array()) { |
58 | - $query = "SELECT 1 FROM `{{users}}` WHERE `id` = " . idval($user['id']) . |
|
59 | - (!empty($planet['id_owner']) ? ' OR `id` = ' . idval($planet['id_owner']) : '') |
|
58 | + $query = "SELECT 1 FROM `{{users}}` WHERE `id` = ".idval($user['id']). |
|
59 | + (!empty($planet['id_owner']) ? ' OR `id` = '.idval($planet['id_owner']) : '') |
|
60 | 60 | . " FOR UPDATE"; |
61 | 61 | |
62 | 62 | static::getDb()->doSelect($query); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | FROM `{{users}}` |
74 | 74 | WHERE |
75 | 75 | `user_as_ally` IS NULL" . |
76 | - ($online ? ' AND `onlinetime` > ' . (SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : '') |
|
76 | + ($online ? ' AND `onlinetime` > '.(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : '') |
|
77 | 77 | )); |
78 | 78 | } |
79 | 79 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | ->fieldCount('r.id', 'referral_count') |
96 | 96 | ->fieldSingleFunction('sum', 'r.dark_matter', 'referral_dm') |
97 | 97 | ->join('LEFT JOIN {{referrals}} as r on r.id_partner = u.id') |
98 | - ->where($online ? "`onlinetime` >= " . intval(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : 'user_as_ally IS NULL') |
|
98 | + ->where($online ? "`onlinetime` >= ".intval(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : 'user_as_ally IS NULL') |
|
99 | 99 | ->groupBy('u.id') |
100 | 100 | ->orderBy("user_as_ally, {$sort} ASC"); |
101 | 101 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | ->where('(`user_birthday_celebrated` IS NULL OR DATE_ADD(`user_birthday_celebrated`, INTERVAL 1 YEAR) < CURRENT_DATE)') |
114 | 114 | ->where('`user_as_ally` IS NULL') |
115 | 115 | ->having('`days_after_birthday` >= 0') |
116 | - ->having('`days_after_birthday` < ' . intval($config_user_birthday_range)) |
|
116 | + ->having('`days_after_birthday` < '.intval($config_user_birthday_range)) |
|
117 | 117 | ->setForUpdate(); |
118 | 118 | |
119 | 119 | $result = $query->selectIterator(); |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | $username_safe = db_escape($like ? strtolower($username_unsafe) : $username_unsafe); // тут на самом деле strtolower() лишняя, но пусть будет |
208 | 208 | |
209 | 209 | $user = classSupernova::$db->doSelectFetch( |
210 | - "SELECT * FROM {{users}} WHERE `username` " . ($like ? 'LIKE' : '=') . " '{$username_safe}'" |
|
210 | + "SELECT * FROM {{users}} WHERE `username` ".($like ? 'LIKE' : '=')." '{$username_safe}'" |
|
211 | 211 | . " FOR UPDATE" |
212 | 212 | ); |
213 | 213 | SnCache::cache_set(LOC_USER, $user); // В кэш-юзер так же заполнять индексы |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | |
258 | 258 | |
259 | 259 | public static function db_user_list_set_mass_mail(&$owners_list, $set) { |
260 | - return classSupernova::$gc->cacheOperator->db_upd_record_list(LOC_USER, $set, !empty($owners_list) ? '`id` IN (' . implode(',', $owners_list) . ');' : ''); |
|
260 | + return classSupernova::$gc->cacheOperator->db_upd_record_list(LOC_USER, $set, !empty($owners_list) ? '`id` IN ('.implode(',', $owners_list).');' : ''); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | public static function db_user_list_set_by_ally_and_rank($ally_id, $ally_rank_id, $set) { |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | * @param array $playerArray |
273 | 273 | */ |
274 | 274 | public static function renderNameAndCoordinates($playerArray) { |
275 | - return "{$playerArray['username']} " . uni_render_coordinates($playerArray); |
|
275 | + return "{$playerArray['username']} ".uni_render_coordinates($playerArray); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | /** |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | $fieldName = pname_resource_name($resourceId); |
304 | 304 | $value = "{$fieldName} = {$fieldName} + ('{$value}')"; |
305 | 305 | } |
306 | - if($query = implode(',', $playerRowFieldChanges)) { |
|
306 | + if ($query = implode(',', $playerRowFieldChanges)) { |
|
307 | 307 | classSupernova::$gc->db->doUpdate("UPDATE `{{users}}` SET {$query} WHERE id = {$userId}"); |
308 | 308 | } |
309 | 309 | } |
@@ -182,8 +182,8 @@ discard block |
||
182 | 182 | $query = $this->db->doSelect( |
183 | 183 | "SELECT |
184 | 184 | distinct({{{$location_info[P_TABLE_NAME]}}}.{$owner_data[P_OWNER_FIELD]}) AS parent_id |
185 | - FROM {{{$location_info[P_TABLE_NAME]}}}" . |
|
186 | - ($filter ? ' WHERE ' . $filter : '') . |
|
185 | + FROM {{{$location_info[P_TABLE_NAME]}}}". |
|
186 | + ($filter ? ' WHERE '.$filter : ''). |
|
187 | 187 | ($fetch ? ' LIMIT 1' : '')); |
188 | 188 | while ($row = db_fetch($query)) { |
189 | 189 | // Исключаем из списка родительских ИД уже заблокированные записи |
@@ -196,13 +196,13 @@ discard block |
||
196 | 196 | if ($indexes_str = implode(',', $parent_id_list)) { |
197 | 197 | $parent_id_field = static::$location_info[$owner_location_type][P_ID]; |
198 | 198 | classSupernova::$gc->cacheOperator->db_get_record_list($owner_location_type, |
199 | - $parent_id_field . (count($parent_id_list) > 1 ? " IN ({$indexes_str})" : " = {$indexes_str}"), $fetch, true); |
|
199 | + $parent_id_field.(count($parent_id_list) > 1 ? " IN ({$indexes_str})" : " = {$indexes_str}"), $fetch, true); |
|
200 | 200 | } |
201 | 201 | } |
202 | 202 | } |
203 | 203 | |
204 | 204 | $query = $this->db->doSelect( |
205 | - "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}" . |
|
205 | + "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}". |
|
206 | 206 | (($filter = trim($filter)) ? " WHERE {$filter}" : '') |
207 | 207 | . " FOR UPDATE" |
208 | 208 | ); |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | $condition = trim($condition); |
277 | 277 | $table_name = static::$location_info[$location_type][P_TABLE_NAME]; |
278 | 278 | |
279 | - if ($result = $this->db->doUpdate("UPDATE {{{$table_name}}} SET " . $set . ($condition ? ' WHERE ' . $condition : ''))) { |
|
279 | + if ($result = $this->db->doUpdate("UPDATE {{{$table_name}}} SET ".$set.($condition ? ' WHERE '.$condition : ''))) { |
|
280 | 280 | |
281 | 281 | if ($this->db->db_affected_rows()) { // Обновляем данные только если ряд был затронут |
282 | 282 | // Поскольку нам неизвестно, что и как обновилось - сбрасываем кэш этого типа полностью |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | public function db_lock_tables($tables) { |
347 | 347 | $tables = is_array($tables) ? $tables : array($tables => ''); |
348 | 348 | foreach ($tables as $table_name => $condition) { |
349 | - $this->db->doSelect("SELECT 1 FROM {{{$table_name}}}" . ($condition ? ' WHERE ' . $condition : '')); |
|
349 | + $this->db->doSelect("SELECT 1 FROM {{{$table_name}}}".($condition ? ' WHERE '.$condition : '')); |
|
350 | 350 | } |
351 | 351 | } |
352 | 352 | } |