/** * * @param boolean $pInclude_relations) * @return boolean */ public function load_from_mb($pID) { $client = new Zend_Rest_Client("http://musicbrainz.org/ws/1/artist/" . $pID); $client->inc('artist-rels release-rels'); $client->type('xml'); $result = $client->get(); if ($result->artist) { $artist_node = $result->artist; $attrs = $artist_node->attributes(); $type = (string) $attrs['type']; $id_field = $this->table()->idField(); $this->table()->getAdapter()->query('REPLACE INTO ' . $this->table()->tableName() . '(' . $id_field . ') values (?)', array($pID)); $select = $this->table()->select()->where('mb_id LIKE ?', array($pID)); $this->_row = $this->table()->fetchRow($select); $this->type = strtolower($type); $relations = array(); foreach ($artist_node->children() as $ele_name => $element) { switch ($ele_name) { case 'life-span': foreach ($element->attributes() as $life_prop => $life_value) { $life_prop = strtolower($life_prop); switch ($life_prop) { case 'begin': case 'end': $this->{$life_prop} = (string) $life_value; } } break; case 'name': $this->name = (string) $element; break; case 'sort-name': // don't care break; case 'relation-list': $list = Zupal_Media_Musicbrains_Relations::digest_list($element, $pID, 'artist'); $relations = array_merge($relations, $list); break; default: // don't care } } if ($relations) { foreach ($relations as $relation) { $this->add_relation($relation); } } $this->save(); } else { return FALSE; } }