本文整理汇总了PHP中Track::loadTrack方法的典型用法代码示例。如果您正苦于以下问题:PHP Track::loadTrack方法的具体用法?PHP Track::loadTrack怎么用?PHP Track::loadTrack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Track
的用法示例。
在下文中一共展示了Track::loadTrack方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buyTrack
public function buyTrack($trackid, $albumid)
{
$userid = $this->session->userdata('userid');
$result = array("error" => FALSE);
if (!$userid) {
$result["error"] = "You must login!";
echo json_encode($result);
}
$user = new User($userid);
$track = Track::loadTrack($trackid);
if ($user->getCredit() < $track->getCost()) {
//The user can't afford the track!
$result["error"] = "You have insufficient funds to buy the track as it costs £" . sprintf("%01.2f", $track->getCost() / 100) . ", please top up your account";
echo json_encode($result);
} else {
//Buy the rights to the track
if ($user->aquireRightsToTrack($trackid, $albumid)) {
//The track was bought successfully
$result["bought"] = TRUE;
} else {
$result["error"] = "Sorry, there was a problem buying the track. Please try again later";
}
echo json_encode($result);
}
}