@@ -38,7 +38,7 @@ |
||
38 | 38 | if ($que_type == QUE_RESEARCH || $planet_id === null) { |
39 | 39 | $query[] = "`que_planet_id` IS NULL"; |
40 | 40 | } elseif ($planet_id) { |
41 | - $query[] = "(`que_planet_id` = {$planet_id}" . ($que_type ? '' : ' OR que_planet_id IS NULL') . ")"; |
|
41 | + $query[] = "(`que_planet_id` = {$planet_id}".($que_type ? '' : ' OR que_planet_id IS NULL').")"; |
|
42 | 42 | } |
43 | 43 | if ($que_type) { |
44 | 44 | $query[] = "`que_type` = {$que_type}"; |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | // TODO - remove or use something else |
40 | 40 | public static function renderNameAndCoordinates($playerArray) { |
41 | - return "{$playerArray['username']} " . uni_render_coordinates($playerArray); |
|
41 | + return "{$playerArray['username']} ".uni_render_coordinates($playerArray); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * @return int |
116 | 116 | */ |
117 | 117 | public static function db_user_count($online = false) { |
118 | - $iterator = static::playerSelectIterator('COUNT(`id`)', '', false, '', ($online ? '`onlinetime` > ' . (SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : '')); |
|
118 | + $iterator = static::playerSelectIterator('COUNT(`id`)', '', false, '', ($online ? '`onlinetime` > '.(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : '')); |
|
119 | 119 | |
120 | 120 | return intval(classSupernova::$db->getDbIteratorFirstValue($iterator)); |
121 | 121 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | LEFT JOIN |
129 | 129 | {{referrals}} as r on r.id_partner = u.id |
130 | 130 | WHERE " . |
131 | - ($online ? "`onlinetime` >= " . intval(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : 'user_as_ally IS NULL') . |
|
131 | + ($online ? "`onlinetime` >= ".intval(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : 'user_as_ally IS NULL'). |
|
132 | 132 | " GROUP BY u.id |
133 | 133 | ORDER BY user_as_ally, {$sort} ASC"; |
134 | 134 | $result = classSupernova::$db->doSelectIterator($query); |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | `{{users}}` |
146 | 146 | WHERE |
147 | 147 | `user_as_ally` IS NULL |
148 | - AND `user_bot` = " . USER_BOT_PLAYER . " |
|
148 | + AND `user_bot` = " . USER_BOT_PLAYER." |
|
149 | 149 | AND `user_birthday` IS NOT NULL |
150 | 150 | AND (`user_birthday_celebrated` IS NULL OR DATE_ADD(`user_birthday_celebrated`, INTERVAL 1 YEAR) < CURRENT_DATE) |
151 | 151 | HAVING |
@@ -166,8 +166,8 @@ discard block |
||
166 | 166 | $query = |
167 | 167 | "SELECT 1 |
168 | 168 | FROM `{{users}}` |
169 | - WHERE `id` = " . idval($user['id']) . |
|
170 | - (!empty($planet['id_owner']) ? ' OR `id` = ' . idval($planet['id_owner']) : '') . |
|
169 | + WHERE `id` = " . idval($user['id']). |
|
170 | + (!empty($planet['id_owner']) ? ' OR `id` = '.idval($planet['id_owner']) : ''). |
|
171 | 171 | " FOR UPDATE"; |
172 | 172 | |
173 | 173 | classSupernova::$db->doSelect($query); |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | $username_safe = db_escape($like ? strtolower($username_unsafe) : $username_unsafe); // тут на самом деле strtolower() лишняя, но пусть будет |
244 | 244 | |
245 | 245 | $user = classSupernova::$db->doSelectFetch( |
246 | - "SELECT * FROM {{users}} WHERE `username` " . ($like ? 'LIKE' : '=') . " '{$username_safe}'" |
|
246 | + "SELECT * FROM {{users}} WHERE `username` ".($like ? 'LIKE' : '=')." '{$username_safe}'" |
|
247 | 247 | . " FOR UPDATE" |
248 | 248 | ); |
249 | 249 | classSupernova::$gc->snCache->cache_set(LOC_USER, $user); // В кэш-юзер так же заполнять индексы |
@@ -40,6 +40,7 @@ discard block |
||
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
43 | + * @param string $fields |
|
43 | 44 | * @return DbResultIterator |
44 | 45 | */ |
45 | 46 | protected static function playerSelectIterator($fields, $orderBy = '', $forUpdate = false, $groupHaving = '', $where = '', $limit = '') { |
@@ -134,6 +135,9 @@ discard block |
||
134 | 135 | return $result; |
135 | 136 | } |
136 | 137 | |
138 | + /** |
|
139 | + * @param integer $config_user_birthday_range |
|
140 | + */ |
|
137 | 141 | public static function db_user_list_to_celebrate($config_user_birthday_range) { |
138 | 142 | $query = "SELECT |
139 | 143 | `id`, `username`, `user_birthday`, `user_birthday_celebrated`, |
@@ -213,6 +217,9 @@ discard block |
||
213 | 217 | return $user_list; |
214 | 218 | } |
215 | 219 | |
220 | + /** |
|
221 | + * @param string $username_unsafe |
|
222 | + */ |
|
216 | 223 | public static function db_user_by_username($username_unsafe, $for_update = false, $fields = '*', $player = null, $like = false) { |
217 | 224 | // TODO Проверить, кстати - а везде ли нужно выбирать юзеров или где-то все-таки ищутся Альянсы ? |
218 | 225 | if (!($username_unsafe = trim($username_unsafe))) { |
@@ -266,7 +273,6 @@ discard block |
||
266 | 273 | |
267 | 274 | /** |
268 | 275 | * @param $user_id |
269 | - * @param array $set |
|
270 | 276 | * @param array $adjust |
271 | 277 | * |
272 | 278 | * @return array|bool|mysqli_result|null |
@@ -283,8 +289,8 @@ discard block |
||
283 | 289 | * <p>array - запись пользователя с установленным полем ['id']</p> |
284 | 290 | * @param bool $for_update @deprecated |
285 | 291 | * @param string $fields @deprecated список полей или '*'/'' для всех полей |
286 | - * @param null $player |
|
287 | - * @param bool|null $player Признак выбора записи пользователь типа "игрок" |
|
292 | + * @param boolean $player |
|
293 | + * @param boolean $player Признак выбора записи пользователь типа "игрок" |
|
288 | 294 | * <p>null - Можно выбрать запись любого типа</p> |
289 | 295 | * <p>true - Выбирается только запись типа "игрок"</p> |
290 | 296 | * <p>false - Выбирается только запись типа "альянс"</p> |
@@ -15,10 +15,10 @@ discard block |
||
15 | 15 | // classSupernova::$db->sn_db_connect(); |
16 | 16 | if (!(strpos($query, '{{') === false)) { |
17 | 17 | foreach ($update_tables as $tableName => $cork) { |
18 | - $query = str_replace("{{{$tableName}}}", classSupernova::$db->db_prefix . $tableName, $query); |
|
18 | + $query = str_replace("{{{$tableName}}}", classSupernova::$db->db_prefix.$tableName, $query); |
|
19 | 19 | } |
20 | 20 | } |
21 | - !($result = classSupernova::$db->db_sql_query($query)) ? die('Query error for ' . $query . ': ' . classSupernova::$db->db_error()) : false; |
|
21 | + !($result = classSupernova::$db->db_sql_query($query)) ? die('Query error for '.$query.': '.classSupernova::$db->db_error()) : false; |
|
22 | 22 | |
23 | 23 | return $result; |
24 | 24 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | global $update_tables, $update_indexes, $update_indexes_full, $update_foreigns; |
86 | 86 | |
87 | 87 | $tableName = $prefixed ? str_replace(classSupernova::$config->db_prefix, '', $prefix_table_name) : $prefix_table_name; |
88 | - $prefix_table_name = $prefixed ? $prefix_table_name : classSupernova::$config->db_prefix . $prefix_table_name; |
|
88 | + $prefix_table_name = $prefixed ? $prefix_table_name : classSupernova::$config->db_prefix.$prefix_table_name; |
|
89 | 89 | |
90 | 90 | upd_unset_table_info($tableName); |
91 | 91 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | $update_indexes_full[$tableName][$r1['Key_name']][$r1['Column_name']] = $r1; |
101 | 101 | } |
102 | 102 | |
103 | - $q1 = upd_do_query("SELECT * FROM `information_schema`.`KEY_COLUMN_USAGE` WHERE `TABLE_SCHEMA` = '" . db_escape(classSupernova::$db_name) . "' AND TABLE_NAME = '{$prefix_table_name}' AND REFERENCED_TABLE_NAME is not null;", true); |
|
103 | + $q1 = upd_do_query("SELECT * FROM `information_schema`.`KEY_COLUMN_USAGE` WHERE `TABLE_SCHEMA` = '".db_escape(classSupernova::$db_name)."' AND TABLE_NAME = '{$prefix_table_name}' AND REFERENCED_TABLE_NAME is not null;", true); |
|
104 | 104 | while ($r1 = db_fetch($q1)) { |
105 | 105 | $table_referenced = str_replace(classSupernova::$config->db_prefix, '', $r1['REFERENCED_TABLE_NAME']); |
106 | 106 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | $result = upd_do_query("CREATE TABLE IF NOT EXISTS `{$db_prefix}{$table_name}` {$declaration}"); |
161 | 161 | $error = classSupernova::$db->db_error(); |
162 | 162 | if ($error) { |
163 | - die("Creating error for table `{$table_name}`: {$error}<br />" . dump($declaration)); |
|
163 | + die("Creating error for table `{$table_name}`: {$error}<br />".dump($declaration)); |
|
164 | 164 | } |
165 | 165 | upd_do_query('set foreign_key_checks = 1;', true); |
166 | 166 | upd_load_table_info($table_name, false); |
@@ -14,10 +14,6 @@ |
||
14 | 14 | $unit_obj = new V2Unit()->load($unit_row); |
15 | 15 | $this->attach($unit_obj, $unit_obj->dbId); |
16 | 16 | } |
17 | - |
|
18 | - |
|
19 | - |
|
20 | - |
|
21 | 17 | * |
22 | 18 | */ |
23 | 19 | } |
@@ -18,6 +18,7 @@ |
||
18 | 18 | protected $unitBySnId; |
19 | 19 | |
20 | 20 | /** |
21 | + * @param integer $locationType |
|
21 | 22 | */ |
22 | 23 | public function load($locationType, $locationId) { |
23 | 24 |
@@ -21,15 +21,15 @@ |
||
21 | 21 | */ |
22 | 22 | public function load($locationType, $locationId) { |
23 | 23 | |
24 | - if(!($unitRows = DBStaticUnit::db_get_unit_list_by_location(0, $locationType, $locationId))) { |
|
24 | + if (!($unitRows = DBStaticUnit::db_get_unit_list_by_location(0, $locationType, $locationId))) { |
|
25 | 25 | return null; |
26 | 26 | } |
27 | 27 | |
28 | 28 | $model = \classSupernova::$gc->unitModel; |
29 | - foreach($unitRows as $dbId => $unitRow) { |
|
29 | + foreach ($unitRows as $dbId => $unitRow) { |
|
30 | 30 | $unit = $model->fromArray($unitRow); |
31 | 31 | $this->attach($unit); |
32 | - if($unit->snId) { |
|
32 | + if ($unit->snId) { |
|
33 | 33 | $this->unitBySnId[$unit->snId] = $unit; |
34 | 34 | } |
35 | 35 | } |
@@ -83,19 +83,19 @@ |
||
83 | 83 | public function importVector(V2FleetContainer $that, array &$row, $propertyName, $fieldName) { |
84 | 84 | $prefix = $propertyName == 'vectorDeparture' ? 'fleet_start_' : 'fleet_end_'; |
85 | 85 | $that->$propertyName = new Vector( |
86 | - $row[$prefix . 'galaxy'], |
|
87 | - $row[$prefix . 'system'], |
|
88 | - $row[$prefix . 'planet'], |
|
89 | - $row[$prefix . 'type'] |
|
86 | + $row[$prefix.'galaxy'], |
|
87 | + $row[$prefix.'system'], |
|
88 | + $row[$prefix.'planet'], |
|
89 | + $row[$prefix.'type'] |
|
90 | 90 | ); |
91 | 91 | } |
92 | 92 | |
93 | 93 | public function exportVector(V2FleetContainer $that, array &$row, $propertyName, $fieldName) { |
94 | 94 | $prefix = $propertyName == 'vectorDeparture' ? 'fleet_start_' : 'fleet_end_'; |
95 | - $row[$prefix . 'galaxy'] = $that->$propertyName->galaxy; |
|
96 | - $row[$prefix . 'system'] = $that->$propertyName->system; |
|
97 | - $row[$prefix . 'planet'] = $that->$propertyName->planet; |
|
98 | - $row[$prefix . 'type'] = $that->$propertyName->type; |
|
95 | + $row[$prefix.'galaxy'] = $that->$propertyName->galaxy; |
|
96 | + $row[$prefix.'system'] = $that->$propertyName->system; |
|
97 | + $row[$prefix.'planet'] = $that->$propertyName->planet; |
|
98 | + $row[$prefix.'type'] = $that->$propertyName->type; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -41,7 +41,7 @@ |
||
41 | 41 | |
42 | 42 | // Checking if index free. NULL index is always free |
43 | 43 | if (isset($this->index[$data])) { |
44 | - throw new \Exception('Duplicate index [' . $data . '] in ' . __CLASS__); |
|
44 | + throw new \Exception('Duplicate index ['.$data.'] in '.__CLASS__); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | if ($data !== null) { |