<?php

class Mapper_Tag extends Fiktiv_Model_Mapper_DbTableAbstract
{
    public function findByBlogPost($id)
    {
        
        $postHasTagsTable = new Table_PosthasTag();

        $rows = $postHasTagsTable->getAdapter()->select()
                        ->from('Post_has_Tag',array())
                        ->join('Tag', 'Tag.id = Post_has_Tag.tagId', array('id', 'name'))
                        ->where('Post_has_Tag.postId = ?', $id)
                        ->query()->fetchAll();

        $tags = array();
        foreach ($rows as $row) {
            $tags[$row['id']] = $row['name'];
        }

        return $tags;
    }
}