本文整理汇总了PHP中Artist::setName方法的典型用法代码示例。如果您正苦于以下问题:PHP Artist::setName方法的具体用法?PHP Artist::setName怎么用?PHP Artist::setName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Artist
的用法示例。
在下文中一共展示了Artist::setName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Artist
$trackId = $track->getId();
// *************************
// *************************
// OBTENGO DATOS DEL ARTISTA
$log->add("getting artist id...");
if ($trackId != NULL) {
$artist = new Artist();
$log->add("searching db for artist=" . $track->getArtistName());
$artist->loadFromName($dbc, $track->getArtistName());
if ($artist->getMaches() == "1") {
$artistId = $artist->getId();
$log->add("found artist={$artistId}");
} else {
$log->add("artist not found");
$log->add("saving new artist info...");
$artist->setName($track->getArtistName());
$savedArtist = $artist->save($dbc, "artistas");
if ($savedArtist == TRUE) {
$artistId = $artist->getId();
$log->add("new artist found={$artistId}...");
} else {
$artistId = NULL;
$log->add("ERROR saving artist");
}
}
}
// *************************
// *************************
// OBTENGO DATOS DEL ALBUM
$log->add("getting album id...");
if ($artistId != NULL) {
示例2: findEvents
public static function findEvents($entityManager, $date)
{
error_log("date: " . $date->format('Y-m-d'));
$query = $entityManager->createQuery('SELECT count(e) FROM Event e WHERE e.date LIKE :date');
$query->setParameter("date", "%" . $date->format('m-d'));
$eventNumber = $query->getSingleScalarResult();
if ($eventNumber) {
error_log("events for " . $date->format('Y-m-d') . " already exist.");
return "1";
}
$dim = new \ThisDayIn\Music($date->format('j'), $date->format('F'));
$evs = $dim->getEvents();
foreach ($evs as $ev) {
$date = new \DateTime($ev['date']);
if ($ev['type'] === 'Death') {
$ev['description'] = sprintf('%s, %s', $ev['name'], $ev['description']);
}
//unlike the death events, the birth events do not include enough information in the description.
if ($ev['type'] === 'Birth') {
$ev['description'] = sprintf('%s, %s was born', $ev['name'], $ev['description']);
}
//must find artist name for these kind of events
if ($ev['type'] == 'Event') {
$artist = self::findEventArtist($ev['description']);
$ev['name'] = $artist['name'];
if (isset($artist['spotifyId'])) {
$ev['spotifyId'] = $artist['spotifyId'];
}
}
#TODO: find artist spotify id for the other event types
//set current event
$event = new \Event();
$event->setDate($date);
$event->setDescription($ev['description']);
$event->setType($ev['type']);
$event->setSource($dim->getSource());
//connects the event to an artist
if ($ev['name']) {
$artist = $entityManager->getRepository('Artist')->findBy(array('name' => $ev['name']));
$artist = array_shift($artist);
if (!$artist) {
$artist = new \Artist();
$artist->setName($ev['name']);
if (isset($ev['spotifyId'])) {
$artist->setSpotifyId($ev['spotifyId']);
}
}
error_log("artist name: " . $artist->getName());
$event->setArtist($artist);
$entityManager->persist($event);
$artist->assignToEvent($event);
$entityManager->persist($artist);
#one must save here so it copes for repeated artist in the event list
$entityManager->flush();
}
$entityManager->persist($event);
}
//insert all events to db
if (count($evs)) {
$entityManager->flush();
}
return 0;
}