本文整理匯總了PHP中Track::searchByArtist方法的典型用法代碼示例。如果您正苦於以下問題:PHP Track::searchByArtist方法的具體用法?PHP Track::searchByArtist怎麽用?PHP Track::searchByArtist使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Track
的用法示例。
在下文中一共展示了Track::searchByArtist方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: search
function search($page = 0, $display = 26)
{
$searchBy = $_POST["search_by"];
$term = $_POST["search_term"];
$userid = $this->session->userdata('userid');
$tracks = array();
try {
if ($searchBy == "name") {
$returned = Track::searchTrackName($term, $userid, $page * $display, $display);
} else {
if ($searchBy == "genre") {
$returned = Track::searchByGenre($term, $userid, $page * $display, $display);
} else {
if ($searchBy == "artist") {
$returned = Track::searchByArtist($term, $userid, $page * $display, $display);
} else {
if ($searchBy == "playlist") {
$this->load->static_model("Playlist");
$returned = Playlist::searchByName($term, $userid, $page * $display, $display);
} else {
echo json_encode(array("error" => "The search criteria is not recognized"));
return;
}
}
}
}
} catch (Exception $e) {
echo json_encode(array("error" => $e->getMessage()));
return;
}
$tracks = $returned['tracks'];
$num_rows = $returned['rows'];
if ($num_rows > $display) {
$num_pages = ceil($num_rows / $display);
} else {
$num_pages = 1;
}
$newTracks = array();
foreach ($tracks as $track) {
$newTracks[] = $track->toArray();
}
$result = array("tracks" => $newTracks, "cur_page" => $page, "num_pages" => $num_pages);
echo json_encode($result);
}