本文整理汇总了PHP中Album::setTracks方法的典型用法代码示例。如果您正苦于以下问题:PHP Album::setTracks方法的具体用法?PHP Album::setTracks怎么用?PHP Album::setTracks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Album
的用法示例。
在下文中一共展示了Album::setTracks方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: extractAlbumInfo
/**
* Extract album information from a SimpleXMLElement object.
*
* @param SimpleXMLElement $album
* @param string $id
* @return Album
*/
private function extractAlbumInfo(SimpleXMLElement $album, $id = null)
{
$artistUse = $album->artist;
if (is_array($album->artist) || isset($album->artist[0])) {
$artistUse = $album->artist[0];
}
$artist = $this->extractArtistInfo($artistUse);
$albumId = $album->attributes();
$albumURI = (string) $albumId['href'];
if ($id != null && isset($id)) {
$albumURI = $id;
}
$currentAlbum = new Album($albumURI, (string) $album->name, (string) $album->released, $artist, (double) $album->popularity);
$territories = explode(' ', (string) $album->availability->territories);
$currentAlbum->setTerritories($territories);
$tracks = array();
if (isset($album->tracks->track)) {
foreach ($album->tracks->track as $track) {
$tracks[] = $this->extractTrackInfo($track, clone $currentAlbum);
}
}
$currentAlbum->setTracks($tracks);
return $currentAlbum;
}
示例2: getAlbumByTitle
function getAlbumByTitle($q)
{
$albums = array();
$sql = "SELECT * FROM Album WHERE Title like :q OR Artist like :q ";
$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$result = $this->db->prepare($sql);
$result->execute(array(":q" => '%' . $q . '%'));
$data = $result->fetchAll(PDO::FETCH_OBJ);
foreach ($data as $unAlbum) {
$album = new Album();
$album->init($unAlbum->IDAlbum, $unAlbum->Title, $unAlbum->Cover, $unAlbum->Artist);
$album->setTracks($this->getAlbumTracks($unAlbum->IDAlbum));
array_push($albums, $album);
}
return $albums;
}