|
@@ 142-149 (lines=8) @@
|
| 139 |
|
"`id_owner` = '{$user_row['id']}' {$conditions} ORDER BY {$order_by}"); |
| 140 |
|
} |
| 141 |
|
|
| 142 |
|
public static function db_planet_list_by_user_or_planet($user_id, $planet_id) { |
| 143 |
|
if (!($user_id = idval($user_id)) && !($planet_id = idval($planet_id))) { |
| 144 |
|
return false; |
| 145 |
|
} |
| 146 |
|
|
| 147 |
|
return classSupernova::$gc->cacheOperator->db_get_record_list(LOC_PLANET, |
| 148 |
|
$planet_id = idval($planet_id) ? "{{planets}}.`id` = {$planet_id}" : "`id_owner` = {$user_id}", $planet_id); |
| 149 |
|
} |
| 150 |
|
|
| 151 |
|
/** |
| 152 |
|
* @param array $planetRowFieldChanges - array of $resourceId => $amount |
|
@@ 281-292 (lines=12) @@
|
| 278 |
|
} |
| 279 |
|
|
| 280 |
|
|
| 281 |
|
public static function db_planet_count_by_type($ui_user_id, $ui_planet_type = PT_PLANET) { |
| 282 |
|
// $si_user_id = intval($ui_user_id); |
| 283 |
|
$si_user_id = idval($ui_user_id); |
| 284 |
|
$si_planet_type = intval($ui_planet_type); |
| 285 |
|
|
| 286 |
|
// Лочим запись-родителя - если она есть и еще не залочена |
| 287 |
|
$record_list = classSupernova::$gc->cacheOperator->db_get_record_list(LOC_PLANET, "`id_owner` = {$si_user_id} AND `planet_type` = {$si_planet_type}"); |
| 288 |
|
|
| 289 |
|
return is_array($record_list) ? count($record_list) : 0; |
| 290 |
|
// $planets = doquery("SELECT COUNT(*) AS planet_count FROM {{planets}} WHERE `id_owner` = {$si_user_id} AND `planet_type` = {$si_planet_type}", true); |
| 291 |
|
// return isset($planets['planet_count']) ? $planets['planet_count'] : 0; |
| 292 |
|
} |
| 293 |
|
|
| 294 |
|
public static function db_planet_list_resources_by_owner() { |
| 295 |
|
return classSupernova::$db->doSelect("SELECT `id_owner`, sum(metal) AS metal, sum(crystal) AS crystal, sum(deuterium) AS deuterium FROM `{{planets}}` WHERE id_owner <> 0 /*AND id_owner is not null*/ GROUP BY id_owner;"); |