Return the data for the given $fieldId.

If no data is found, null is returned.

@param int $fieldId
@param int $versionNo

@return array|null
184613
protected function loadFieldData($fieldId, $versionNo)
    {
        $selectQuery = $this->connection->createQueryBuilder();
        $selectQuery
            ->select(
                $this->connection->quoteIdentifier('latitude'),
                $this->connection->quoteIdentifier('longitude'),
                $this->connection->quoteIdentifier('address')
            )
            ->from($this->connection->quoteIdentifier('ezgmaplocation'))
            ->where(
                $selectQuery->expr()->andX(
                    $selectQuery->expr()->eq(
                        $this->connection->quoteIdentifier('contentobject_attribute_id'),
                        ':fieldId'
                    ),
                    $selectQuery->expr()->eq(
                        $this->connection->quoteIdentifier('contentobject_version'),
                        ':versionNo'
                    )
                )
            )
            ->setParameter(':fieldId', $fieldId, PDO::PARAM_INT)
            ->setParameter(':versionNo', $versionNo, PDO::PARAM_INT)
        ;

        $statement = $selectQuery->execute();

        $rows = $statement->fetchAll(PDO::FETCH_ASSOC);
        if (!isset($rows[0])) {
            return null;
        }

        // Cast coordinates as the DB can return them as strings
        $rows[0]['latitude'] = (float)$rows[0]['latitude'];
        $rows[0]['longitude'] = (float)$rows[0]['longitude'];

        return $rows[0];
    }
6771
public function deleteNodeAssignment($contentId, $versionNo = null)
    {
        try {
            return $this->innerGateway->deleteNodeAssignment($contentId, $versionNo);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
719582
public function getFileReferenceData($fieldId, $versionNo)
    {
        $connection = $this->getConnection();

        $selectQuery = $connection->createSelectQuery();

        $this->setFetchColumns($selectQuery, $fieldId, $versionNo);

        $selectQuery->from(
            $connection->quoteTable($this->getStorageTable())
        )->where(
            $selectQuery->expr->lAnd(
                $selectQuery->expr->eq(
                    $connection->quoteColumn('contentobject_attribute_id'),
                    $selectQuery->bindValue($fieldId, null, \PDO::PARAM_INT)
                ),
                $selectQuery->expr->eq(
                    $connection->quoteColumn('version'),
                    $selectQuery->bindValue($versionNo, null, \PDO::PARAM_INT)
                )
            )
        );

        $statement = $selectQuery->prepare();
        $statement->execute();

        $result = $statement->fetchAll(\PDO::FETCH_ASSOC);

        if (count($result) < 1) {
            return null;
        }

        $convertedResult = array();
        foreach (reset($result) as $column => $value) {
            $convertedResult[$this->toPropertyName($column)] = $this->castToPropertyValue($value, $column);
        }
        $convertedResult['id'] = $this->prependMimeToPath(
            $convertedResult['id'],
            $convertedResult['mimeType']
        );

        return $convertedResult;
    }
266916
public function deleteFieldData(VersionInfo $versionInfo, array $fieldIds)
    {
        $query = $this->connection->createQueryBuilder();
        $query->delete('ngsyliusproduct')
            ->where(
                $query->expr()->eq('contentobject_id', ':contentobject_id')
            )
            ->setParameter('contentobject_id', $versionInfo->contentInfo->id, Type::INTEGER);

        $query->execute();
    }
720261
public function getOneVersion($versionNumber, $con = null)
    {
        return ChildDealerAdminVersionQuery::create()
            ->filterByDealerAdmin($this)
            ->filterByVersion($versionNumber)
            ->findOne($con);
    }
228253
public function removeFileReferences(array $fieldIds, $versionNo)
    {
        if (empty($fieldIds)) {
            return;
        }

        $deleteQuery = $this->connection->createQueryBuilder();
        $deleteQuery
            ->delete($this->connection->quoteIdentifier($this->getStorageTable()))
            ->where(
                $deleteQuery->expr()->andX(
                    $deleteQuery->expr()->in(
                        $this->connection->quoteIdentifier('contentobject_attribute_id'),
                        ':fieldIds'
                    ),
                    $deleteQuery->expr()->eq(
                        $this->connection->quoteIdentifier('version'),
                        ':versionNo'
                    )
                )
            )
            ->setParameter(':fieldIds', $fieldIds, Connection::PARAM_INT_ARRAY)
            ->setParameter(':versionNo', $versionNo, PDO::PARAM_INT)
        ;

        $deleteQuery->execute();
    }
631186
protected function fetchVersionValue(VersionFieldMetadata $versionProperty, array $id)
    {
        $versionedClass = $versionProperty->getDeclaringClass();
        $tableName      = $versionedClass->table->getQuotedQualifiedName($this->platform);
        $columnName     = $this->platform->quoteIdentifier($versionProperty->getColumnName());
        $identifier     = array_map(
            function ($columnName) {
                return $this->platform->quoteIdentifier($columnName);
            },
            array_keys($versionedClass->getIdentifierColumns($this->em))
        );

        // FIXME: Order with composite keys might not be correct
        $sql = 'SELECT ' . $columnName
             . ' FROM ' . $tableName
             . ' WHERE ' . implode(' = ? AND ', $identifier) . ' = ?';

        $flattenedId = $this->em->getIdentifierFlattener()->flattenIdentifier($versionedClass, $id);
        $versionType = $versionProperty->getType();

        $value = $this->conn->fetchColumn(
            $sql,
            array_values($flattenedId),
            0,
            $this->extractIdentifierTypes($id, $versionedClass)
        );

        return $versionType->convertToPHPValue($value, $this->platform);
    }
541845
public function deleteTranslatedFields($languageCode, $contentId, $versionNo = null)
    {
        $query = $this->connection->createQueryBuilder();
        $query
            ->delete('ezcontentobject_attribute')
            ->where('contentobject_id = :contentId')
            ->andWhere('language_code = :languageCode')
            ->setParameters(
                [
                    ':contentId' => $contentId,
                    ':languageCode' => $languageCode,
                ]
            )
        ;

        if (null !== $versionNo) {
            $query
                ->andWhere('version = :versionNo')
                ->setParameter(':versionNo', $versionNo)
            ;
        }

        $query->execute();
    }
495370
public function getOneVersion($versionNumber, $con = null)
    {
        return ChildDealerVersionQuery::create()
            ->filterByDealer($this)
            ->filterByVersion($versionNumber)
            ->findOne($con);
    }
1149577
public function deleteRelations($contentId, $versionNo = null)
    {
        $query = $this->dbHandler->createDeleteQuery();
        $query->deleteFrom(
            $this->dbHandler->quoteTable('ezcontentobject_link')
        );

        if (isset($versionNo)) {
            $query->where(
                $query->expr->lAnd(
                    $query->expr->eq(
                        $this->dbHandler->quoteColumn('from_contentobject_id'),
                        $query->bindValue($contentId, null, \PDO::PARAM_INT)
                    ),
                    $query->expr->eq(
                        $this->dbHandler->quoteColumn('from_contentobject_version'),
                        $query->bindValue($versionNo, null, \PDO::PARAM_INT)
                    )
                )
            );
        } else {
            $query->where(
                $query->expr->lOr(
                    $query->expr->eq(
                        $this->dbHandler->quoteColumn('from_contentobject_id'),
                        $query->bindValue($contentId, null, \PDO::PARAM_INT)
                    ),
                    $query->expr->eq(
                        $this->dbHandler->quoteColumn('to_contentobject_id'),
                        $query->bindValue($contentId, null, \PDO::PARAM_INT)
                    )
                )
            );
        }

        $query->prepare()->execute();
    }
40490
public function getFieldData( VersionInfo $versionInfo, Field $field )
    {
        $field->value->externalData = $this->loadFieldData( $versionInfo, $field );
    }
1076697
public function linkUrl($urlId, $fieldId, $versionNo)
    {
        $query = $this->connection->createQueryBuilder();

        $query
            ->insert($this->connection->quoteIdentifier(self::URL_LINK_TABLE))
            ->values(
                [
                    'contentobject_attribute_id' => ':contentobject_attribute_id',
                    'contentobject_attribute_version' => ':contentobject_attribute_version',
                    'url_id' => ':url_id',
                ]
            )
            ->setParameter(':contentobject_attribute_id', $fieldId, PDO::PARAM_INT)
            ->setParameter(':contentobject_attribute_version', $versionNo, PDO::PARAM_INT)
            ->setParameter(':url_id', $urlId, PDO::PARAM_INT)
        ;

        $query->execute();
    }
862326
public function getRecord($id, $versionID = null)
    {
        if (!$id) {
            return null;
        }
        $treeClass = $this->config()->get('tree_class');
        if ($id instanceof $treeClass) {
            return $id;
        }
        if (substr($id, 0, 3) == 'new') {
            return $this->getNewItem($id);
        }
        if (!is_numeric($id)) {
            return null;
        }

        $currentStage = Versioned::get_reading_mode();

        if ($this->getRequest()->getVar('Version')) {
            $versionID = (int) $this->getRequest()->getVar('Version');
        }

        /** @var SiteTree $record */
        if ($versionID) {
            $record = Versioned::get_version($treeClass, $id, $versionID);
        } else {
            $record = DataObject::get_by_id($treeClass, $id);
        }

        // Then, try getting a record from the live site
        if (!$record) {
            // $record = Versioned::get_one_by_stage($treeClass, "Live", "\"$treeClass\".\"ID\" = $id");
            Versioned::set_stage(Versioned::LIVE);
            singleton($treeClass)->flushCache();

            $record = DataObject::get_by_id($treeClass, $id);
        }

        // Then, try getting a deleted record
        if (!$record) {
            $record = Versioned::get_latest_version($treeClass, $id);
        }

        // Set the reading mode back to what it was.
        Versioned::set_reading_mode($currentStage);

        return $record;
    }
1096313
public function deleteFieldData($fieldType, VersionInfo $versionInfo, array $ids)
    {
        $this->storageRegistry->getStorage($fieldType)
            ->deleteFieldData($versionInfo, $ids, $this->context);
    }
45848
public function getOneVersion($versionNumber, $con = null)
    {
        return ChildDealerProductVersionQuery::create()
            ->filterByDealerProduct($this)
            ->filterByVersion($versionNumber)
            ->findOne($con);
    }
959323
public function getFileReferenceData($fieldId, $versionNo)
    {
        $selectQuery = $this->connection->createQueryBuilder();

        $this->setFetchColumns($selectQuery, $fieldId, $versionNo);

        $selectQuery
            ->from($this->connection->quoteIdentifier($this->getStorageTable()))
            ->where(
                $selectQuery->expr()->andX(
                    $selectQuery->expr()->eq(
                        $this->connection->quoteIdentifier('contentobject_attribute_id'),
                        ':fieldId'
                    ),
                    $selectQuery->expr()->eq(
                        $this->connection->quoteIdentifier('version'),
                        ':versionNo'
                    )
                )
            )
            ->setParameter(':fieldId', $fieldId, PDO::PARAM_INT)
            ->setParameter(':versionNo', $versionNo, PDO::PARAM_INT)
        ;

        $statement = $selectQuery->execute();

        $result = $statement->fetchAll(PDO::FETCH_ASSOC);

        if (count($result) < 1) {
            return null;
        }

        $convertedResult = [];
        foreach (reset($result) as $column => $value) {
            $convertedResult[$this->toPropertyName($column)] = $this->castToPropertyValue($value, $column);
        }
        $convertedResult['id'] = $this->prependMimeToPath(
            $convertedResult['id'],
            $convertedResult['mimeType']
        );

        return $convertedResult;
    }
711823
protected function updateFieldData(VersionInfo $versionInfo, Field $field)
    {
        $updateQuery = $this->connection->createQueryBuilder();
        $updateQuery->update($this->connection->quoteIdentifier(self::MAP_LOCATION_TABLE))
            ->set($this->connection->quoteIdentifier('latitude'), ':latitude')
            ->set($this->connection->quoteIdentifier('longitude'), ':longitude')
            ->set($this->connection->quoteIdentifier('address'), ':address')
            ->where(
                $updateQuery->expr()->andX(
                    $updateQuery->expr()->eq(
                        $this->connection->quoteIdentifier('contentobject_attribute_id'),
                        ':fieldId'
                    ),
                    $updateQuery->expr()->eq(
                        $this->connection->quoteIdentifier('contentobject_version'),
                        ':versionNo'
                    )
                )
            )
            ->setParameter(':latitude', $field->value->externalData['latitude'])
            ->setParameter(':longitude', $field->value->externalData['longitude'])
            ->setParameter(':address', $field->value->externalData['address'])
            ->setParameter(':fieldId', $field->id, PDO::PARAM_INT)
            ->setParameter(':versionNo', $versionInfo->versionNo, PDO::PARAM_INT)
        ;

        $updateQuery->execute();
    }