本文整理汇总了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");
}
}
}