本文整理汇总了PHP中Track::searchByGenre方法的典型用法代码示例。如果您正苦于以下问题:PHP Track::searchByGenre方法的具体用法?PHP Track::searchByGenre怎么用?PHP Track::searchByGenre使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Track
的用法示例。
在下文中一共展示了Track::searchByGenre方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
function index()
{
$this->load->static_model('Track');
//$this->load->view('welcome_message');
$search_res = Track::searchByGenre("opera");
//$data = array('search_res' => $search_res);
//$this->load->view('search', $data);
$t = $search_res[0];
print_r($t->getArtist()->getTracks());
/*foreach( as $t){
echo $t->getName().", artist: ".$t->getArtist()->getName().", album: ".$t->getAlbum()->getName().", genres: ";
print_r($t->getGenres());
echo ", videos: ";
print_r($t->getVideos())."<br />";
}*/
}
示例2: 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);
}