當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Track::searchByGenre方法代碼示例

本文整理匯總了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 />";
     		}*/
 }
開發者ID:bennetimo,項目名稱:comp3013,代碼行數:16,代碼來源:welcome.php

示例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);
 }
開發者ID:bennetimo,項目名稱:comp3013,代碼行數:44,代碼來源:trackmanager.php


注:本文中的Track::searchByGenre方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。