Metrics

From ETC Public Wiki
Jump to: navigation, search

Saving game data for metrics

Development Tool: MySQL Database, Javascript, phpMyAdmin and PHP5.


MySQL: Design database schema.


DBschema.jpg



Using PHP and Ajax(Using XMLhttp), send query to database while players are playing.


In game code, put database function to send data.

Example(Updating battle information when game ended)


updateDB_BattleInfo(TotalTimeTaken, NoOfGamePauses, BattleResult, GoldLeft, GoldPickedUp)

Using XMLhttp request send query to database whenever users are doing certain action.

function updateDB_BattleInfo(TotalTimeTaken, NoOfGamePauses, BattleResult, GoldLeft, GoldPickedUp){
if(window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
}
xmlhttp.open("GET", "updateBattleInfo.php?TotalTimeTaken="+TotalTimeTaken+
"&NoOfGamePauses="+NoOfGamePauses+
"&BattleResult="+BattleResult+
"&GoldLeft="+GoldLeft+
"&GoldPickedUp="+GoldPickedUp,true);
xmlhttp.send();
}

Using PHP file, our game sends query to database.

Example(updateBattleInfo.php file)

$query = "UPDATE BattleInfo SET TotalTimeTaken='$TotalTimeTaken',
NoOfGamePauses='$NoOfGamePauses',
BattleResult='$BattleResult',
GoldLeft='$GoldLeft',
GoldPickedUp='$GoldPickedUp'
WHERE BattleID='$battleID'";
$result = mysql_query($query,$connect);


After record data, to analyze database we are using phpMyAdmin.

phpMyAdmin is an open source tool written in PHP intended to handle the administration of MySQL over the World Wide Web. [1]