本文整理汇总了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);
}