当前位置: 首页>>代码示例>>PHP>>正文


PHP Track::searchTrackName方法代码示例

本文整理汇总了PHP中Track::searchTrackName方法的典型用法代码示例。如果您正苦于以下问题:PHP Track::searchTrackName方法的具体用法?PHP Track::searchTrackName怎么用?PHP Track::searchTrackName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Track的用法示例。


在下文中一共展示了Track::searchTrackName方法的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);
 }
开发者ID:bennetimo,项目名称:comp3013,代码行数:44,代码来源:trackmanager.php


注:本文中的Track::searchTrackName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。