public function getWithAssociation($associationIndex, $associatedId)
    {
        $oConfig = Factory::service('Config');
        $oConfig->load('blog/blog');

        $associations = $oConfig->item('blog_post_associations');

        if (!isset($associations[$associationIndex])) {
            return [];
        }

        $oDb = Factory::service('Database');
        $oDb->select('post_id');
        $oDb->where('associated_id', $associatedId);
        $posts = $oDb->get($associations[$associationIndex]->target)->result();

        $ids = [];
        foreach ($posts as $post) {
            $ids[] = $post->post_id;
        }

        if (empty($ids)) {
            //  No IDs? No posts.
            return [];
        }

        $oDb->where_in($this->tableAlias . '.id', $ids);

        return $this->getAll();
    }
public function getWithAssociation($associationIndex, $associatedId)
    {
        $oConfig = Factory::service('Config');
        $oConfig->load('blog/blog');

        $associations = $oConfig->item('blog_post_associations');

        if (!isset($associations[$associationIndex])) {
            return [];
        }

        $oDb = Factory::service('Database');
        $oDb->select('post_id');
        $oDb->where('associated_id', $associatedId);
        $posts = $oDb->get($associations[$associationIndex]->target)->result();

        $ids = [];
        foreach ($posts as $post) {
            $ids[] = $post->post_id;
        }

        if (empty($ids)) {
            //  No IDs? No posts.
            return [];
        }

        $oDb->where_in($this->tableAlias . '.id', $ids);

        return $this->getAll();
    }
public function getWithAssociation ( $ associationIndex , $ associatedId ) { $ oConfig = Factory :: service ( 'Config' ) ; $ oConfig -> load ( 'blog/blog' ) ; $ associations = $ oConfig -> item ( 'blog_post_associations' ) ; if ( ! isset ( $ associations [ $ associationIndex ] ) ) { return [ ] ; } $ oDb = Factory :: service ( 'Database' ) ; $ oDb -> select ( 'post_id' ) ; $ oDb -> where ( 'associated_id' , $ associatedId ) ; $ posts = $ oDb -> get ( $ associations [ $ associationIndex ] -> target ) -> result ( ) ; $ ids = [ ] ; foreach ( $ posts as $ post ) { $ ids [ ] = $ post -> post_id ; } if ( empty ( $ ids ) ) { //  No IDs? No posts. return [ ] ; } $ oDb -> where_in ( $ this -> tableAlias . '.id' , $ ids ) ; return $ this -> getAll ( ) ; }
Get posts with a particular association

@param  int $associationIndex The association's index
@param  int $associatedId     The Id of the item to be associated with

@return array
Get posts with a particular association