本文整理匯總了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);
}
}