public function servicesAction() { $posts = Post::find(array('conditions' => 'is_service = 1', 'limit' => 5)); $tags = array(); foreach ($posts as $index => $post) { $pts = PostTag::find(array('conditions' => 'post_id = ?1', 'bind' => array(1 => $post->id))); $tags[$index] = array(); foreach ($pts as $pt) { $tags[$index][] = Tag::findFirst(array('conditions' => 'id = ?1', 'bind' => array(1 => $pt->tag_id))); } } $this->view->setParamToView('posts', $posts); $this->view->setParamToView('tags', $tags); }