Respuesta: Datos especificos en una fila DB Cita:
Iniciado por gnzsoloyo Por lo pronto, si tienes todos esos datos en un mismo campo de la tabla, lo que tienes es un (perdón por decirlo así) espantoso, desastroso diseño de datos, que es totalmente inútil para realizar consultas.
Todos esos datos deben ir en campos diferentes de la tabla, e incluso puede que algunos se necesite ponerlos en tablas separadas relacionadas por pK (caso e-Mail, teléfono, etc). claro yo entiendo a lo que te refieres pero el código ya esta así y es un proyecto que aun se esta desarrollando. se trata de un juego para ios y android pero este desarrollador logro hacer un servidor para el juego con lo cuál tu puedes hacer tu propio server de ese juego bueno sin más comparto el código. Código PHP: -- Database: `ucsdb`
--
-- --------------------------------------------------------
--
-- Table structure for table `clan`
--
DROP TABLE IF EXISTS `clan`;
CREATE TABLE IF NOT EXISTS `clan` (
`ClanId` int(11) NOT NULL,
`LastUpdateTime` datetime NOT NULL,
`SerializedData` text NOT NULL,
PRIMARY KEY (`ClanId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `player`
--
DROP TABLE IF EXISTS `player`;
CREATE TABLE IF NOT EXISTS `player` (
`PlayerId` int(11) NOT NULL,
`LastUpdateTime` datetime NOT NULL,
`SerializedData` text NOT NULL,
PRIMARY KEY (`PlayerId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
al crear un nuevo usuario o registro de jugador en el juego se crean 3 campus: playerid, ultima conexión y serializeddata que este ultimo es donde guarda toda la información del usuario Código PHP: {"FlagPlayerHasClan":1,"LastUpdate":1413592963,"Login":"1603001413590662","Region":170,"PlayerId":160300,"Village":{"android_client":true,"buildings":[{"data":1000001,"lvl":1,"x":21,"y":20},{"data":1000014,"lvl":0,"locked":false,"x":25,"y":32},{"data":1000015,"lvl":0,"x":21,"y":24}],"obstacles":[],"decos":[],"respawnVars":{"secondsFromLastRespawn":10,"respawnSeed":10,"obstacleClearCounter":10,"time_to_gembox_drop":10,"time_in_gembox_period":10},"cooldowns":[],"newShopBuildings":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"newShopTraps":[0,0,0,0,0,0,0,0],"newShopDecos":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"last_league_rank":0,"last_league_shuffle":0,"last_news_seen":10,"edit_mode_shown":false,"war_tutorials_seen":false,"war_base":false},"PlayerName":"JorgeMoralesMV","FlagPlayerHasName":1,"EndShieldTime":1413594262,"ClanId":1,"Level":9,"Experience":115,"CurrentGems":777500,"Trophies":0,"TutorialStepsCount":13,"Units":{"0":{"Name":"Barbarian","Id":4000000,"Index":0,"Level":0,"Count":0},"1":{"Name":"Archer","Id":4000001,"Index":1,"Level":0,"Count":0},"2":{"Name":"Goblin","Id":4000002,"Index":2,"Level":0,"Count":0},"3":{"Name":"Giant","Id":4000003,"Index":3,"Level":0,"Count":0},"4":{"Name":"Wall Breaker","Id":4000004,"Index":4,"Level":0,"Count":0},"5":{"Name":"Balloon","Id":4000005,"Index":5,"Level":0,"Count":0},"6":{"Name":"Wizard","Id":4000006,"Index":6,"Level":0,"Count":0},"7":{"Name":"Healer","Id":4000007,"Index":7,"Level":0,"Count":0},"8":{"Name":"Dragon","Id":4000008,"Index":8,"Level":0,"Count":0},"9":{"Name":"PEKKA","Id":4000009,"Index":9,"Level":0,"Count":0},"10":{"Name":"Gargoyle","Id":4000010,"Index":10,"Level":0,"Count":0},"11":{"Name":"Boar Rider","Id":4000011,"Index":11,"Level":0,"Count":0},"12":{"Name":"Warrior Girl","Id":4000012,"Index":12,"Level":0,"Count":0},"13":{"Name":"Golem","Id":4000013,"Index":13,"Level":0,"Count":0},"14":{"Name":"Golem Secondary","Id":4000014,"Index":14,"Level":0,"Count":0},"15":{"Name":"Warlock","Id":4000015,"Index":15,"Level":0,"Count":0},"16":{"Name":"Skeleton","Id":4000016,"Index":16,"Level":0,"Count":0},"17":{"Name":"AirDefenceSeeker","Id":4000017,"Index":17,"Level":0,"Count":0},"18":{"Name":"AirDefenceSeekerFragment","Id":4000018,"Index":18,"Level":0,"Count":0}},"NpcLevels":{"0":{"Name":"TutorialNPC","Id":17000000,"Index":0,"Stars":0,"LootedGold":0,"LootedElixir":0},"1":{"Name":"TutorialNPC2","Id":17000001,"Index":1,"Stars":0,"LootedGold":0,"LootedElixir":0},"2":{"Name":"NPC1","Id":17000002,"Index":2,"Stars":0,"LootedGold":0,"LootedElixir":0},"3":{"Name":"NPC2","Id":17000003,"Index":3,"Stars":0,"LootedGold":0,"LootedElixir":0},"4":{"Name":"NPC3","Id":17000004,"Index":4,"Stars":0,"LootedGold":0,"LootedElixir":0},"5":{"Name":"NPC4","Id":17000005,"Index":5,"Stars":0,"LootedGold":0,"LootedElixir":0},"6":{"Name":"NPC5","Id":17000006,"Index":6,"Stars":0,"LootedGold":0,"LootedElixir":0},"7":{"Name":"NPC6","Id":17000007,"Index":7,"Stars":0,"LootedGold":0,"LootedElixir":0},"8":{"Name":"NPC7","Id":17000008,"Index":8,"Stars":0,"LootedGold":0,"LootedElixir":0},"9":{"Name":"NPC8","Id":17000009,"Index":9,"Stars":0,"LootedGold":0,"LootedElixir":0},"10":{"Name":"NPC9","Id":17000010,"Index":10,"Stars":0,"LootedGold":0,"LootedElixir":0},"11":{"Name":"NPC10","Id":17000011,"Index":11,"Stars":0,"LootedGold":0,"LootedElixir":0},"12":{"Name":"NPC11","Id":17000012,"Index":12,"Stars":0,"LootedGold":0,"Status":0}}]}
por último este es el código que uso para generar la lista de usuarios de mi servidor. Código PHP: <?php
$sql1 = "select * from player";
$resulta1 = mysql_query($sql1);
while($row1 = mysql_fetch_array($resulta1)){
echo "<table width=\"578\" border=\"1\">
<tr>
<td width=\"20\"><div align=\"center\">Player ID</div></td>
<td width=\"50\"><div align=\"center\">Ultima Conexión</div></td>
<td width=\"80\"><div align=\"center\">Nombre </div></td>
</tr>";
echo " <tr>
<td><div align=\"center\">$row1[0]</div></td>
<td><div align=\"center\">$row1[1]</div></td>
<td><div align=\"center\">$row1[2]</div></td>
</tr>
</table>
";
}
?> |