本文整理汇总了PHP中Artist类的典型用法代码示例。如果您正苦于以下问题:PHP Artist类的具体用法?PHP Artist怎么用?PHP Artist使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Artist类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDetails
/**
* Gets details from the referenced artist
*
* @param String[Required] $id
* @return String
*/
public function getDetails($id)
{
// If it's an ajax search
$json_content = file_get_contents('php://input');
if ($json_content) {
// Gets JSON request to read country name typed
$data = json_decode($json_content);
$id = $data->id;
$response = array();
// Gets details from artist
$artist = new Artist();
$artist_info = $artist->getById($id);
$response['name'] = $artist_info['name'];
$response['img'] = $artist_info['img'];
// Gets top tracks
$response['tracks'] = $artist->getTopTracks($id);
// Returns JSON for AngularJS
print json_encode($response);
exit;
}
// If it's a GET request, just displays the HTML
$template = 'views/artist/details.html';
$html = file_get_contents($template);
$html = str_replace('$id', $id, $html);
print $html;
}
示例2: afterUpdate
public function afterUpdate($id, $data = null)
{
$artist = Artist::where('artistName', '=', $data['artist'])->where('ownerId', '=', Auth::user()->_id)->first();
if ($artist == null) {
$artist = new Artist();
}
$artist->artistName = $data['artist'];
$artist->ownerId = Auth::user()->_id;
$artist->ownerName = Auth::user()->firstname . ' ' . Auth::user()->lastname;
$artist->save();
return $id;
}
示例3: getList
function getList($params = NULL, $proyection = '*', $order = '1', $limit = '')
{
if ($this->db != NULL) {
$this->db->read($this->table, $proyection, $params);
$r = array();
while ($param = $this->db->getRow()) {
$artist = new Artist();
$artist->set($param);
$r[] = $artist;
}
return $r;
}
return NULL;
}
示例4: read
public static function read($id)
{
global $db;
if ($db) {
$q = $db->prepare('SELECT * FROM `artist` WHERE id = ?');
$q->execute(array($id));
if ($item = $q->fetch()) {
$artist = new Artist($item['name'], $item['origin'], $item['active_years']);
$artist->setID($item['id']);
return $item;
}
}
return false;
}
示例5: testRemoveAlbumFromArtist
public function testRemoveAlbumFromArtist()
{
$artist = Artist::create('id', 'Artist name');
$artist->addAlbum(Album::create('id', 'Album name'));
$artist->removeAlbum(Album::create('id', 'Album name'));
$this->assertCount(0, $artist->getAlbums());
}
示例6: getList
function getList($pagina = 1, $orden = "", $nrpp = Configuracion::NRPP, $condicion = "1=1", $parametros = array())
{
$ordenPredeterminado = "{$orden}, email";
if (trim($orden) === "" || trim($orden) === NULL) {
$ordenPredeterminado = "titulo";
}
$registroInicial = ($pagina - 1) * $nrpp;
$this->bd->select($this->tabla, "*", $condicion, $parametros, $ordenPredeterminado, "{$registroInicial}, {$nrpp}");
$r = array();
while ($fila = $this->bd->getRow()) {
$artista = new Artist();
$artista->set($fila);
$r[] = $artista;
}
return $r;
}
示例7: removeArtist
public function removeArtist($id)
{
$artist = Artist::find($id);
$name = $artist->name;
$artist->delete();
return Redirect::route('account')->with('status', 'alert-success')->with('global', 'You just deleted ' . $name);
}
示例8: imageFromArtist
/**
*
* @param Artist $artist Infos of the artist
* @return resource Resource of the image
*/
public static function imageFromArtist(Artist $artist)
{
$image = null;
$path = self::$baseDirectoryLogos . $artist->getPathLogo();
switch ($artist->getExtensionLogo()) {
case 'gif':
$image = imagecreatefromgif($path);
break;
case 'jpeg':
case 'jpg':
$image = imagecreatefromjpeg($path);
break;
case 'png':
$image = imagecreatefrompng($path);
break;
}
return $image;
}
示例9: testStructureData
/**
* @covers Artist::structureData
*/
public function testStructureData()
{
$this->object->id = '50';
$this->object->name = 'artistName50';
$artist = $this->object->structureData();
$this->assertInstanceOf(Artist::class, $artist, 'Result should be an instance of Artist class');
$this->assertEquals(50, $artist->id, 'Id should be convert in integer');
$this->assertEquals('artistName50', $artist->name, 'Name should be set to artistName50, but found:' . $artist->name);
}
示例10: getWeeklyArtistChart
/** Get an artist chart for a group, for a given date range. If no date range is supplied, it will return the most recent album chart for this group.
*
* @param string $group The last.fm group name to fetch the charts of. (Required)
* @param integer $from The date at which the chart should start from. See {@link de.felixbruns.lastfm.Group#getWeeklyChartList Group::getWeeklyChartList} for more. (Optional)
* @param integer $to The date at which the chart should end on. See {@link de.felixbruns.lastfm.Group#getWeeklyChartList Group::getWeeklyChartList} for more. (Optional)
* @return array An array of Artist objects.
*
* @static
* @access public
* @throws Error
*/
public static function getWeeklyArtistChart($group, $from = null, $to = null)
{
$xml = CallerFactory::getDefaultCaller()->call('group.getWeeklyArtistChart', array('group' => $group, 'from' => $from, 'to' => $to));
$artists = array();
foreach ($xml->children() as $artist) {
$artists[] = Artist::fromSimpleXMLElement($artist);
}
return $artists;
}
示例11: getTopArtists
/** Get the most popular artists on last.fm by country.
*
* @param string country A country name, as defined by the ISO 3166-1 country names standard. (Required)
* @return array An array of Artist objects.
*
* @static
* @access public
* @throws Error
*/
public static function getTopArtists($country)
{
$xml = CallerFactory::getDefaultCaller()->call('geo.getTopArtists', array('country' => $country));
$artists = array();
foreach ($xml->children() as $artist) {
$artists[] = Artist::fromSimpleXMLElement($artist);
}
return $artists;
}
示例12: addArtist
/**
* Add an Artist to the database or get its key if it exists
* @param name str: the name of the artist to add
* @return int: the primary key added or found
*/
public function addArtist($name)
{
//is this name already in the collection?
$q = Doctrine_Query::create()->select('a.id')->from('Artist a')->where('a.name = ?', $name);
$result = $q->fetchOne();
if (is_object($result) && $result->id > 0) {
$retId = $result->id;
unset($q, $result);
return (int) $retId;
} else {
$item = new Artist();
$item->name = $name;
$item->save();
$id = $item->getId();
$item->free();
unset($item, $q, $result);
return (int) $id;
}
}
示例13: add_artists
public function add_artists($artists)
{
if (!is_array($artists)) {
$artists = array($artists);
}
foreach ($artists as $artist) {
if ($artist == "") {
continue;
}
$exists = Artists::get_by_name($artist);
if ($exists) {
$exists->add_to_track($this);
} else {
$object = new Artist();
$object->set_name($artist);
$object->add_to_track($this);
}
}
}
示例14: execute
public function execute($smarty, $params, $session)
{
$smarty->assign('name', $session['screen_name']);
$artists = Artist::findAll();
$smarty->assign('artists', $artists);
$songs = Song::findAll();
$smarty->assign('songs', $songs);
$parts = Part::findAll();
$smarty->assign('parts', $parts);
$smarty->display('index.tpl');
}
示例15: insertAndGet
public static function insertAndGet($pdo, $name)
{
$st = $pdo->prepare('select * from artists where name = ?');
$st->execute(array($name));
if ($row = $st->fetch()) {
return Artist::factory($row);
} else {
$st = $pdo->prepare('insert into artists(name) values(?)');
$st->execute(array($name));
return self::insertAndGet($pdo, $name);
}
}