当前位置: 首页>>代码示例>>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;未经允许,请勿转载。