public function storeFieldData(VersionInfo $versionInfo, $productId)
    {
        $contentId = $versionInfo->contentInfo->id;

        $selectQuery = $this->connection->createQueryBuilder();
        $selectQuery->select('DISTINCT contentobject_id')
            ->from('ngsyliusproduct')
            ->where(
                $selectQuery->expr()->eq('contentobject_id', ':contentobject_id')
            )
            ->setParameter('contentobject_id', $contentId, Type::INTEGER);

        $statement = $selectQuery->execute();

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

        if (count($rows) > 0) {
            $query = $this->connection->createQueryBuilder();
            $query
                ->update('ngsyliusproduct')
                ->set('product_id', ':product_id')
                ->where(
                    $query->expr()->eq('contentobject_id', ':contentobject_id')
                )
                ->setParameter('product_id', $productId, Type::INTEGER)
                ->setParameter('contentobject_id', $contentId, Type::INTEGER)
            ;
        } else {
            $query = $this->connection->createQueryBuilder();
            $query
                ->insert('ngsyliusproduct')
                ->values(
                    array(
                        'product_id' => ':product_id',
                        'contentobject_id' => ':contentobject_id',
                    )
                )
                ->setParameter('product_id', $productId, Type::INTEGER)
                ->setParameter('contentobject_id', $contentId, Type::INTEGER)
            ;
        }

        $query->execute();
    }
public function storeFieldData(VersionInfo $versionInfo, $productId)
    {
        $contentId = $versionInfo->contentInfo->id;

        $selectQuery = $this->connection->createQueryBuilder();
        $selectQuery->select('DISTINCT contentobject_id')
            ->from('ngsyliusproduct')
            ->where(
                $selectQuery->expr()->eq('contentobject_id', ':contentobject_id')
            )
            ->setParameter('contentobject_id', $contentId, Type::INTEGER);

        $statement = $selectQuery->execute();

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

        if (count($rows) > 0) {
            $query = $this->connection->createQueryBuilder();
            $query
                ->update('ngsyliusproduct')
                ->set('product_id', ':product_id')
                ->where(
                    $query->expr()->eq('contentobject_id', ':contentobject_id')
                )
                ->setParameter('product_id', $productId, Type::INTEGER)
                ->setParameter('contentobject_id', $contentId, Type::INTEGER)
            ;
        } else {
            $query = $this->connection->createQueryBuilder();
            $query
                ->insert('ngsyliusproduct')
                ->values(
                    array(
                        'product_id' => ':product_id',
                        'contentobject_id' => ':contentobject_id',
                    )
                )
                ->setParameter('product_id', $productId, Type::INTEGER)
                ->setParameter('contentobject_id', $contentId, Type::INTEGER)
            ;
        }

        $query->execute();
    }
public function storeFieldData ( VersionInfo $ versionInfo , $ productId ) { $ contentId = $ versionInfo -> contentInfo -> id ; $ selectQuery = $ this -> connection -> createQueryBuilder ( ) ; $ selectQuery -> select ( 'DISTINCT contentobject_id' ) -> from ( 'ngsyliusproduct' ) -> where ( $ selectQuery -> expr ( ) -> eq ( 'contentobject_id' , ':contentobject_id' ) ) -> setParameter ( 'contentobject_id' , $ contentId , Type :: INTEGER ) ; $ statement = $ selectQuery -> execute ( ) ; $ rows = $ statement -> fetchAll ( PDO :: FETCH_ASSOC ) ; if ( count ( $ rows ) > 0 ) { $ query = $ this -> connection -> createQueryBuilder ( ) ; $ query -> update ( 'ngsyliusproduct' ) -> set ( 'product_id' , ':product_id' ) -> where ( $ query -> expr ( ) -> eq ( 'contentobject_id' , ':contentobject_id' ) ) -> setParameter ( 'product_id' , $ productId , Type :: INTEGER ) -> setParameter ( 'contentobject_id' , $ contentId , Type :: INTEGER ) ; } else { $ query = $ this -> connection -> createQueryBuilder ( ) ; $ query -> insert ( 'ngsyliusproduct' ) -> values ( array ( 'product_id' => ':product_id' , 'contentobject_id' => ':contentobject_id' , ) ) -> setParameter ( 'product_id' , $ productId , Type :: INTEGER ) -> setParameter ( 'contentobject_id' , $ contentId , Type :: INTEGER ) ; } $ query -> execute ( ) ; }
Stores the data in the database based on the given field data.

@param \eZ\Publish\SPI\Persistence\Content\VersionInfo $versionInfo
@param int $productId
Stores the data in the database based on the given field data .