statisticsmanager definestatsmetadata
This commit is contained in:
parent
1f6e77101f
commit
35c1bf0c08
@ -19,6 +19,7 @@ class StatisticManager {
|
|||||||
* Private Properties
|
* Private Properties
|
||||||
*/
|
*/
|
||||||
private $maniaControl = null;
|
private $maniaControl = null;
|
||||||
|
private $mysqli = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct player manager
|
* Construct player manager
|
||||||
@ -27,32 +28,63 @@ class StatisticManager {
|
|||||||
*/
|
*/
|
||||||
public function __construct(ManiaControl $maniaControl) {
|
public function __construct(ManiaControl $maniaControl) {
|
||||||
$this->maniaControl = $maniaControl;
|
$this->maniaControl = $maniaControl;
|
||||||
|
$this->mysqli = $this->maniaControl->database->mysqli;
|
||||||
$this->initTables();
|
$this->initTables();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines a Stat
|
||||||
|
*
|
||||||
|
* @param string $statName
|
||||||
|
* @param string $statDescription
|
||||||
|
*/
|
||||||
|
public function defineStatMetaData($statName, $statDescription = '') {
|
||||||
|
$query = "INSERT IGNORE INTO `" . self::TABLE_STATMETADATA . "` (
|
||||||
|
`name`,
|
||||||
|
`description`
|
||||||
|
) VALUES (
|
||||||
|
?, ?
|
||||||
|
);";
|
||||||
|
$statement = $this->mysqli->prepare($query);
|
||||||
|
if($this->mysqli->error) {
|
||||||
|
trigger_error($this->mysqli->error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$statement->bind_param('ss', $statName, $statDescription);
|
||||||
|
$statement->execute();
|
||||||
|
if($statement->error) {
|
||||||
|
trigger_error($statement->error);
|
||||||
|
$statement->close();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$statement->close();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize necessary database tables
|
* Initialize necessary database tables
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function initTables() {
|
private function initTables() {
|
||||||
$mysqli = $this->maniaControl->database->mysqli;
|
|
||||||
$query = "CREATE TABLE IF NOT EXISTS `" . self::TABLE_STATMETADATA . "` (
|
$query = "CREATE TABLE IF NOT EXISTS `" . self::TABLE_STATMETADATA . "` (
|
||||||
`index` int(11) NOT NULL AUTO_INCREMENT,
|
`index` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`name` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
|
`name` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
|
||||||
`description` varchar(150) COLLATE utf8_unicode_ci NOT NULL,
|
`description` varchar(150) COLLATE utf8_unicode_ci,
|
||||||
PRIMARY KEY (`index`),
|
PRIMARY KEY (`index`),
|
||||||
UNIQUE KEY `name` (`name`)
|
UNIQUE KEY `name` (`name`)
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Statistics Meta Data' AUTO_INCREMENT=1;";
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Statistics Meta Data' AUTO_INCREMENT=1;";
|
||||||
|
|
||||||
$statement = $mysqli->prepare($query);
|
$statement = $this->mysqli->prepare($query);
|
||||||
if ($mysqli->error) {
|
if($this->mysqli->error) {
|
||||||
trigger_error($mysqli->error, E_USER_ERROR);
|
trigger_error($this->mysqli->error, E_USER_ERROR);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$statement->execute();
|
$statement->execute();
|
||||||
if($statement->error) {
|
if($statement->error) {
|
||||||
trigger_error($statement->error, E_USER_ERROR);
|
trigger_error($statement->error, E_USER_ERROR);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$statement->close();
|
$statement->close();
|
||||||
@ -65,14 +97,16 @@ class StatisticManager {
|
|||||||
UNIQUE KEY `unique` (`statId`,`playerId`,`serverId`)
|
UNIQUE KEY `unique` (`statId`,`playerId`,`serverId`)
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Statistics Meta Data' AUTO_INCREMENT=1;";
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Statistics Meta Data' AUTO_INCREMENT=1;";
|
||||||
|
|
||||||
$statement = $mysqli->prepare($query);
|
$statement = $this->mysqli->prepare($query);
|
||||||
if ($mysqli->error) {
|
if($this->mysqli->error) {
|
||||||
trigger_error($mysqli->error, E_USER_ERROR);
|
trigger_error($this->mysqli->error, E_USER_ERROR);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$statement->execute();
|
$statement->execute();
|
||||||
if($statement->error) {
|
if($statement->error) {
|
||||||
trigger_error($statement->error, E_USER_ERROR);
|
trigger_error($statement->error, E_USER_ERROR);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$statement->close();
|
$statement->close();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user