本文整理汇总了PHP中DbHandler::createPlayer方法的典型用法代码示例。如果您正苦于以下问题:PHP DbHandler::createPlayer方法的具体用法?PHP DbHandler::createPlayer怎么用?PHP DbHandler::createPlayer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DbHandler
的用法示例。
在下文中一共展示了DbHandler::createPlayer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: function
* method POST
* url /players
*/
$app->post('/players', function () use($app) {
$response = array();
if (in_array("admin", $app->jwt->roles)) {
// if(true) {
$body = json_decode($app->request()->getBody());
$firstName = $body->{'FirstName'};
$surName = $body->{'SurName'};
$surNamePrefix = $body->{'SurNamePrefix'};
$dateOfBirth = $body->{'DateOfBirth'};
$relationCode = $body->{'RelationCode'};
$emailAddress = $body->{'EmailAddress'};
$db = new DbHandler();
$playerID = $db->createPlayer($firstName, $surName, $surNamePrefix, $dateOfBirth, $relationCode, $emailAddress);
if ($playerID != NULL) {
$response["Error"] = false;
$response["Message"] = "Player created successfully";
$response["PlayerID"] = $playerID;
} else {
$response["Error"] = true;
$response["Message"] = "Failed to create player. Please try again";
}
echoRespnse(201, $response);
} else {
/* No scope so respond with 401 Unauthorized */
echoRespnse(401, $response);
}
});
/**
示例2: array
$response = array();
$db = new DbHandler();
$result = $db->checkIsSetup($user_id);
$response["exist"] = $result;
echoRespnse(200, $response);
});
$app->post('/create_player', 'authenticate', function () use($app) {
// check for required params
verifyRequiredParams(array('skin', 'hair', 'hair_color'));
$response = array();
$skin = $app->request->post('skin');
$hair = $app->request->post('hair');
$hair_color = $app->request->post('hair_color');
global $user_id;
$db = new DbHandler();
$player_id = $db->createPlayer($user_id, $skin, $hair, $hair_color);
if ($player_id == 0) {
$response["error"] = false;
$response["message"] = "Player created successfully";
$response["player_id"] = $player_id;
echoRespnse(201, $response);
} else {
$response["error"] = true;
$response["message"] = "Failed to create player. Please try again";
echoRespnse(200, $response);
}
});
$app->post('/update_player', 'authenticate', function () use($app) {
// check for required params
verifyRequiredParams(array('cloth', 'headwear'));
global $user_id;