本文整理匯總了PHP中Artist::getId方法的典型用法代碼示例。如果您正苦於以下問題:PHP Artist::getId方法的具體用法?PHP Artist::getId怎麽用?PHP Artist::getId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Artist
的用法示例。
在下文中一共展示了Artist::getId方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: 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;
}
}
示例2: Artist
$saved = $track->save($dbc, "temas");
if ($saved === TRUE) {
// *************************
// OBTENGO DATOS DEL TRACK
$log->add("getting track id...");
$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");
}
}
}