From 4837b46e8782671c697fe36c5a22e8131ab79c84 Mon Sep 17 00:00:00 2001 From: Exodus4D Date: Tue, 10 Nov 2015 22:41:21 +0100 Subject: [PATCH] close #50 changed table names back to "default" camelCase names, fixed map query bug --- app/main/controller/api/map.php | 23 +++++++++++++++++------ app/main/controller/api/route.php | 6 +++--- app/main/controller/api/system.php | 12 ++++++------ app/main/model/mapmodel.php | 11 +++++++++-- app/pathfinder.ini | 2 +- 5 files changed, 36 insertions(+), 18 deletions(-) diff --git a/app/main/controller/api/map.php b/app/main/controller/api/map.php index 8a1bc6f3..cfd3f4c8 100644 --- a/app/main/controller/api/map.php +++ b/app/main/controller/api/map.php @@ -175,6 +175,10 @@ class Map extends \Controller\AccessController { isset($mapData['data']['systems']) && isset($mapData['data']['connections']) ){ + if(isset($mapData['id'])){ + unset($mapData['id']); + } + $map->setData($mapData['config']); $map->typeId = (int)$importData['typeId']; $map->save(); @@ -184,6 +188,9 @@ class Map extends \Controller\AccessController { $tempSystemIdMapping = []; foreach($mapData['data']['systems'] as $systemData){ + if(isset($systemData['id'])){ + unset($systemData['id']); + } $system->setData($systemData); $system->mapId = $map; $system->createdCharacterId = $activeCharacter->characterId; @@ -200,6 +207,10 @@ class Map extends \Controller\AccessController { isset( $tempSystemIdMapping[$connectionData['source']] ) && isset( $tempSystemIdMapping[$connectionData['target']] ) ){ + if(isset($connectionData['id'])){ + unset($connectionData['id']); + } + $connection->setData($connectionData); $connection->mapId = $map; $connection->source = $tempSystemIdMapping[$connectionData['source']]; @@ -502,10 +513,10 @@ class Map extends \Controller\AccessController { foreach($systems as $i => $systemData){ // check if current system belongs to the current map - $map->filter('systems', array('id = ?', $systemData['id'] )); + $map->filter('systems', ['id = ?', $systemData['id'] ]); $filteredMap = $map->find( - array('id = ?', $map->id ), - array('limit' => 1) + ['id = ?', $map->id ], + ['limit' => 1] ); // this should never fail @@ -531,10 +542,10 @@ class Map extends \Controller\AccessController { foreach($connections as $i => $connectionData){ // check if the current connection belongs to the current map - $map->filter('connections', array('id = ?', $connectionData['id'] )); + $map->filter('connections', ['id = ?', $connectionData['id'] ]); $filteredMap = $map->find( - array('id = ?', $map->id ), - array('limit' => 1) + ['id = ?', $map->id ], + ['limit' => 1] ); // this should never fail diff --git a/app/main/controller/api/route.php b/app/main/controller/api/route.php index 3fbfc767..2d46a3cc 100644 --- a/app/main/controller/api/route.php +++ b/app/main/controller/api/route.php @@ -217,14 +217,14 @@ class Route extends \Controller\AccessController { SELECT GROUP_CONCAT( NULLIF(map_sys_inner.solarSystemName, NULL) SEPARATOR ':') FROM - mapsolarsystemjumps map_jump INNER JOIN - mapsolarsystems map_sys_inner ON + mapSolarSystemJumps map_jump INNER JOIN + mapSolarSystems map_sys_inner ON map_sys_inner.solarSystemID = map_jump.toSolarSystemID WHERE map_jump.fromSolarSystemID = map_sys.solarSystemID ) system_neighbours FROM - mapsolarsystems map_sys + mapSolarSystems map_sys HAVING -- skip systems without neighbors (e.g. WHs) system_neighbours IS NOT NULL diff --git a/app/main/controller/api/system.php b/app/main/controller/api/system.php index 10c85a27..3b2a78f4 100644 --- a/app/main/controller/api/system.php +++ b/app/main/controller/api/system.php @@ -26,8 +26,8 @@ class System extends \Controller\AccessController { SELECT LOWER( system_effect.typeName ) FROM - invtypes system_effect INNER JOIN - mapdenormalize map_norm ON + invTypes system_effect INNER JOIN + mapDenormalize map_norm ON map_norm.typeID = system_effect.typeID WHERE system_effect.groupID = 995 AND @@ -39,16 +39,16 @@ class System extends \Controller\AccessController { SELECT map_worm_class.wormholeClassID system_class FROM - maplocationwormholeclasses map_worm_class + mapLocationWormholeClasses map_worm_class WHERE map_worm_class.locationID = map_sys.regionID LIMIT 1 ), 7) security FROM - mapsolarsystems map_sys INNER JOIN - mapconstellations map_con ON + mapSolarSystems map_sys INNER JOIN + mapConstellations map_con ON map_con.constellationID = map_sys.constellationID INNER JOIN - mapregions map_reg ON + mapRegions map_reg ON map_reg.regionID = map_sys.regionID"; private $whereQuery = ""; diff --git a/app/main/model/mapmodel.php b/app/main/model/mapmodel.php index 9edae3e7..7634d05a 100644 --- a/app/main/model/mapmodel.php +++ b/app/main/model/mapmodel.php @@ -202,7 +202,11 @@ class MapModel extends BasicModel { */ public function getSystems(){ // orderBy x-Coordinate for cleaner frontend animation (left to right) - $this->filter('systems', ['active = ?', 1], ['order' => 'posX']); + $this->filter('systems', + ['active = :active AND id > 0', + ':active' => 1 + ], + ['order' => 'posX']); $systems = []; if($this->systems){ @@ -233,7 +237,10 @@ class MapModel extends BasicModel { * @return array|mixed */ public function getConnections(){ - $this->filter('connections', ['active = ?', 1]); + $this->filter('connections', [ + 'active = :active AND source > 0 AND target > 0', + ':active' => 1 + ]); $connections = []; if($this->connections){ diff --git a/app/pathfinder.ini b/app/pathfinder.ini index 5c68bfc6..df0fdf59 100644 --- a/app/pathfinder.ini +++ b/app/pathfinder.ini @@ -39,7 +39,7 @@ DB_PASS = ; EVE-Online CCP Database export DB_CCP_DNS = mysql:host=localhost;port=3306;dbname= -DB_CCP_NAME = eve_test +DB_CCP_NAME = eve_parallax DB_CCP_USER = root DB_CCP_PASS =