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


PHP Song::playlistSongCount方法代码示例

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


在下文中一共展示了Song::playlistSongCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getPlaylistSongs

 public static function getPlaylistSongs($search_words, $sort_letter, $start, $limit, $search_fields)
 {
     //Set some bounds
     if ($start <= 0) {
         $start = 0;
     }
     if ($limit <= 5) {
         $limit = 5;
     }
     //Set search filters
     $doSearchTitle = !$search_fields || $search_fields == 't';
     // Title
     $doSearchArtist = !$search_fields || $search_fields == 'a';
     // Artist
     $doSearchAlbum = !$search_fields || $search_fields == 'album';
     // Album
     $doSearchGenre = !$search_fields || $search_fields == 'g';
     // Genre
     $db = Database::getInstance();
     $select_where = $db->select();
     $select_where->where('songtype = ?', 'S')->where('status = ?', 0);
     /* ORIGINAL CODE
     		
     		if (is_array($search_words)) {
     			reset($search_words);
     			while (list($key, $val) = each($search_words)) {
     				$val = "%$val%";
     				
     				if($doSearchTitle)
     					$whereFields[] = $db->quoteInto('(title like ?)', $val);
     				if($doSearchArtist)
     					$whereFields[] = $db->quoteInto('(artist like ?)', $val);
     				if($doSearchAlbum)
     					$whereFields[] = $db->quoteInto('(album like ?)', $val);
     				
     				$orWhere[] = implode(' OR ', $whereFields);
     			}
     
     			$select_where->where(implode(' OR ', $orWhere));
     		}
     		*/
     if (is_array($search_words)) {
         reset($search_words);
         while (list($key, $val) = each($search_words)) {
             // $val = search string
             // Check if string contains one word, or multiple.
             // If only one word in the string is present, use % for wildcard around $val to help expand results.
             $val = "{$val}%";
             if (preg_match("/ /", $val)) {
                 $val = "%{$val}%";
             } else {
                 $val = "%{$val}%";
             }
             if ($doSearchTitle) {
                 $whereFields[] = $db->quoteInto('(title like ?)', $val);
             }
             if ($doSearchArtist) {
                 $whereFields[] = $db->quoteInto('(artist like ?)', $val);
             }
             if ($doSearchAlbum) {
                 $whereFields[] = $db->quoteInto('(album like ?)', $val);
             }
             if ($doSearchGenre) {
                 $whereFields[] = $db->quoteInto('(genre like ?)', $val);
             }
             $orWhere[] = implode(' OR ', $whereFields);
         }
         $select_where->where(implode(' OR ', $orWhere));
     }
     if ($sort_letter == '0') {
         $select_where->where($db->quoteInto('NOT((artist>=?)', 'A') . ' AND ' . $db->quoteInto('(artist<?))', 'ZZZZZZZZZZZ'));
     } elseif ($sort_letter != '') {
         $nextletter = chr(ord($sort_letter) + 1);
         $select_where->where($db->quoteInto('(artist>=?)', $sort_letter) . ' AND ' . $db->quoteInto('(artist<?)', $nextletter));
     }
     //Calculate total
     $total_select = clone $select_where;
     $total_select->from('songlist', array('cnt' => 'count(*)'));
     try {
         $row = $db->fetchRow($total_select);
     } catch (Zend_Db_Adapter_Exception $ex) {
         echo "Please verify database settings.<br />";
         exit;
     }
     self::$playlistSongCount = $row['CNT'];
     //Now grab a section of that
     $playlist_select = $select_where;
     $playlist_select->from('songlist')->order(array('artist ASC', 'title ASC'))->limit($limit, $start);
     try {
         $rows = $db->fetchAll($playlist_select);
         $songs = array();
         foreach ($rows as $key => $row) {
             $songs[$key] = new self();
             $songs[$key]->setValues($row);
         }
     } catch (Zend_Db_Adapter_Exception $ex) {
         echo "Please verify database settings.<br />";
         exit;
     }
     return $songs;
//.........这里部分代码省略.........
开发者ID:KiloooNL,项目名称:radio,代码行数:101,代码来源:class.song.php


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