public function insert($document)
    {
        $class     = $this->dm->getClassMetadata(get_class($document));
        $changeset = $this->uow->getDocumentChangeSet($document);
        $qb        = $this->dm->createQueryBuilder($this->class->name);

        foreach ($class->propertyMetadata as $mapping) {
            $new = isset($changeset[$mapping->name][1]) ? $changeset[$mapping->name][1] : null;

            if (($new === null && !$mapping->nullable) || $mapping->isInverseSide) {
                continue;
            }

            if ($mapping->isMany()) {
                if ($mapping->strategy === PropertyMetadata::STORAGE_STRATEGY_ADD_TO_SET || $new->isEmpty()) {
                    continue;
                }

                $this->uow->unscheduleCollectionDeletion($new);
                $this->uow->unscheduleCollectionUpdate($new);
            }

            $qb->attr($mapping->name)->put($new);
        }

        //add a conditional preventing the resulting PutItem from overwriting
        //an existing record with the same primary key
        $class->createIdentifier($document)->addNotExistsToQueryCondition($qb->expr);

        $qb->getQuery()->execute();
    }
public function insert($document)
    {
        $class     = $this->dm->getClassMetadata(get_class($document));
        $changeset = $this->uow->getDocumentChangeSet($document);
        $qb        = $this->dm->createQueryBuilder($this->class->name);

        foreach ($class->propertyMetadata as $mapping) {
            $new = isset($changeset[$mapping->name][1]) ? $changeset[$mapping->name][1] : null;

            if (($new === null && !$mapping->nullable) || $mapping->isInverseSide) {
                continue;
            }

            if ($mapping->isMany()) {
                if ($mapping->strategy === PropertyMetadata::STORAGE_STRATEGY_ADD_TO_SET || $new->isEmpty()) {
                    continue;
                }

                $this->uow->unscheduleCollectionDeletion($new);
                $this->uow->unscheduleCollectionUpdate($new);
            }

            $qb->attr($mapping->name)->put($new);
        }

        //add a conditional preventing the resulting PutItem from overwriting
        //an existing record with the same primary key
        $class->createIdentifier($document)->addNotExistsToQueryCondition($qb->expr);

        $qb->getQuery()->execute();
    }
public function insert ( $ document ) { $ class = $ this -> dm -> getClassMetadata ( get_class ( $ document ) ) ; $ changeset = $ this -> uow -> getDocumentChangeSet ( $ document ) ; $ qb = $ this -> dm -> createQueryBuilder ( $ this -> class -> name ) ; foreach ( $ class -> propertyMetadata as $ mapping ) { $ new = isset ( $ changeset [ $ mapping -> name ] [ 1 ] ) ? $ changeset [ $ mapping -> name ] [ 1 ] : null ; if ( ( $ new === null && ! $ mapping -> nullable ) || $ mapping -> isInverseSide ) { continue ; } if ( $ mapping -> isMany ( ) ) { if ( $ mapping -> strategy === PropertyMetadata :: STORAGE_STRATEGY_ADD_TO_SET || $ new -> isEmpty ( ) ) { continue ; } $ this -> uow -> unscheduleCollectionDeletion ( $ new ) ; $ this -> uow -> unscheduleCollectionUpdate ( $ new ) ; } $ qb -> attr ( $ mapping -> name ) -> put ( $ new ) ; } //add a conditional preventing the resulting PutItem from overwriting //an existing record with the same primary key $ class -> createIdentifier ( $ document ) -> addNotExistsToQueryCondition ( $ qb -> expr ) ; $ qb -> getQuery ( ) -> execute ( ) ; }
Insert the provided document.

@param object $document

@return void
Insert the provided document .