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
348737
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();
    }
322260
protected function getAssociationProperties($associated)
    {
        $associations = $this->_table->associations();
        $result = [];

        foreach ($associated as $name) {
            $result[] = $associations->get($name)->getProperty();
        }

        return $result;
    }
741418
public function delete_related_badge($relatedid) {
        global $DB;
        $sql = "(badgeid = :badgeid AND relatedbadgeid = :relatedid) OR " .
               "(badgeid = :relatedid2 AND relatedbadgeid = :badgeid2)";
        $params = ['badgeid' => $this->id, 'badgeid2' => $this->id, 'relatedid' => $relatedid, 'relatedid2' => $relatedid];
        return $DB->delete_records_select('badge_related', $sql, $params);
    }
740213
def get_association(id, **kwargs):
    
    results = search_associations(id=id, **kwargs)
    assoc = results['associations'][0] if len(results['associations']) > 0 else {}
    return assoc
948033
private function getAssociations() : array
    {
        $result = [];
        foreach ($this->getQueryFields() as $field) {
            $association = $this->getAssociationByField($field);
            if (null === $association) {
                continue;
            }

            if (array_key_exists($association->getName(), $result)) {
                continue;
            }

            $result[$association->getName()] = $association;
        }

        return $result;
    }
576275
protected function getDefaultAssociationFilter()
    {
        $filter = new AssociationFilter();
        $filter->setInsideAssociationID($this->arguments[self::ARGUMENT_INSIDEASSOCIATIONID]);

        return $filter;
    }
1136653
public function findByAssociationAndID($association, $fid, $functionaryFilter = null)
    {
        $xmlQuery = $this->associationsApiService->getFunctionaryFromAssociation($association->getID(), $fid, $functionaryFilter);

        $functionary = new Functionary();

        $mapper = new \RGU\Dvoconnector\Mapper\Functionary($xmlQuery);
        $mapper->mapToAbstractEntity($functionary);

        return $this->completeEntity($functionary);
    }
1082296
public function findByAssociationAndID($association, $eid, $eventFilter = null)
    {
        $xmlQuery = $this->associationsApiService->getEventFromAssociation($association->getID(), $eid, $eventFilter);

        $event = new Event();

        $mapper = new \RGU\Dvoconnector\Mapper\Event($xmlQuery);
        $mapper->mapToAbstractEntity($event);

        return $this->completeEntity($event);
    }
158829
public function findAssociationRepertoires()
    {
        $xmlQuery = $this->metaApiService->getAssociationRepertoires();

        $repertoires = new Repertoires();

        $mapper = new \RGU\Dvoconnector\Mapper\AssociationRepertoires($xmlQuery);
        $mapper->mapToAbstractEntity($repertoires);

        return $repertoires;
    }
1128457
protected function hasOne($associatedClass, $foreignKey = null, $mappingKeyInBaseTable = null)
    {
        return $this->findHasOneOrMany($associatedClass, $foreignKey, $mappingKeyInBaseTable);
    }
473637
public static function getEntity($associatedObj = null)
    {
        $EntityClass = get_called_class();
        $entityClassRef = new $EntityClass();
        $ActualEntity = ModelEntity::generateClassPath($entityClassRef->getShortName());

        $entityRef = class_exists($ActualEntity) ? new $ActualEntity() : new ModelEntity();
        $entityRef->bindToObject($associatedObj);
        return $entityRef;
    }
691403
function getAssociations(instance, ids, callback) {
  instance.db.find({ _id: { $in: ids } }, function(err, associations) {
    for(var cAssociation = 0; cAssociation < associations.length;
        cAssociation++) {
      associations[cAssociation].deviceId = associations[cAssociation]._id;
    }
    callback(err, associations);
  });
}
1055009
public function fetchAssocs(string $statement, array $bindings = [], $indexKey = null): array
    {
        $data = [];
        $sth = $this->execute($statement, $bindings);

        while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
            if ($indexKey) {
                $data[$row[$indexKey]] = $row;
            } else {
                $data[] = $row;
            }
            // $data[current($row)] = $row;
        }

        $this->freeResource($sth);

        return $data;
    }
1132207
public function setAssociationMapping($associationMapping)
    {
        if (!\is_array($associationMapping)) {
            throw new \InvalidArgumentException('The association mapping must be an array');
        }

        $this->associationMapping = $associationMapping;

        if (isset($associationMapping['type'])) {
            $this->type = $this->type ?: $associationMapping['type'];
            $this->mappingType = $this->mappingType ?: $associationMapping['type'];
        } else {
            throw new \InvalidArgumentException('Unknown association mapping type');
        }
        $this->fieldName = $associationMapping['fieldName'];
    }
432673
static public function fetchRelatedObjectsID( $objectID, $attributeID, $allRelations)
    {
        if ( !is_array( $allRelations ) || $allRelations === array() )
        {
            $allRelations = array( 'common', 'xml_embed', 'attribute' );
            if ( eZContentObject::isObjectRelationTyped() )
            {
                $allRelations[] = 'xml_link';
            }
        }

        $relatedObjectsTyped = array();
        foreach ( $allRelations as $relationType )
        {
            $relatedObjectsTyped[$relationType] =
                eZContentFunctionCollection::fetchRelatedObjects( $objectID, $attributeID, array( $relationType ), false, array() );
        }

        $relatedObjectsTypedIDArray = array();
        foreach ( $relatedObjectsTyped as $relationTypeName => $relatedObjectsByType )
        {
            $relatedObjectsTypedIDArray[$relationTypeName] = array();
            foreach ( $relatedObjectsByType['result'] as $relatedObjectByType )
            {
                $relatedObjectsTypedIDArray[$relationTypeName][] = $relatedObjectByType->ID;
            }
        }

        return array( 'result' => $relatedObjectsTypedIDArray );
    }
893670
public function get_related_badges(bool $activeonly = false) {
        global $DB;

        $params = array('badgeid' => $this->id, 'badgeid2' => $this->id, 'badgeid3' => $this->id);
        $query = "SELECT DISTINCT b.id, b.name, b.version, b.language, b.type
                    FROM {badge_related} br
                    JOIN {badge} b ON (br.relatedbadgeid = b.id OR br.badgeid = b.id)
                   WHERE (br.badgeid = :badgeid OR br.relatedbadgeid = :badgeid2) AND b.id != :badgeid3";
        if ($activeonly) {
            $query .= " AND b.status <> :status";
            $params['status'] = BADGE_STATUS_INACTIVE;
        }
        $relatedbadges = $DB->get_records_sql($query, $params);
        return $relatedbadges;
    }
1156329
public function associated($associated)
    {
        $associated = $this->_normalizeAssociations($associated);
        $this->_associated($this->_table, $associated);
        $this->_options['associated'] = $associated;

        return $this;
    }