public function addTag($tag_name) { $tag_hash = md5($tag_name); if (!LernmarktplatzTag::find($tag_hash)) { $tag = new LernmarktplatzTag(); $tag->setId($tag_hash); $tag['name'] = $tag_name; $tag->store(); } $statement = DBManager::get()->prepare("\n INSERT IGNORE INTO lernmarktplatz_tags_material\n SET tag_hash = :tag_hash,\n material_id = :material_id\n "); return $statement->execute(array('tag_hash' => $tag_hash, 'material_id' => $this->getId())); }