src/flowcode/ceibo/support/DaoSupport.php
public function updateRelations($entity) {
        $mapper = MapperBuilder::buildFromMapping($this->mapping, get_class($entity));
        foreach ($mapper->getRelations() as $relation) {
            if ($relation->getCardinality() == Relation::$manyToMany) {
                // delete previous relations
                $queryDeletePrevious = $this->buildDeleteRelationQuery($relation, $entity);
                $this->conn->executeNonQuery($queryDeletePrevious);

                // insert new relations
                $queryRel = $this->buildRelationQuery($entity);
                foreach (explode(";", $queryRel) as $q) {
                    if (strlen($q) > 5)
                        $this->conn->executeInsert($q);
                }
            }
            if ($relation->getCardinality() == Relation::$oneToMany) {
                $relMapper = MapperBuilder::buildFromName($this->mapping, $relation->getEntity());
                $m = "get" . $relation->getName();
                $setid = "set" . $relMapper->getNameForColumn($relation->getForeignColumn());

                // save actual relations
                foreach ($entity->$m() as $relEntity) {
                    $relEntity->$setid($entity->getId());
                    $this->save($relEntity);
                }

                //  delete old relations.
                // TODO: delete old relations
            }
        }
    }
public function updateRelations($entity) {
        $mapper = MapperBuilder::buildFromMapping($this->mapping, get_class($entity));
        foreach ($mapper->getRelations() as $relation) {
            if ($relation->getCardinality() == Relation::$manyToMany) {
                // delete previous relations
                $queryDeletePrevious = $this->buildDeleteRelationQuery($relation, $entity);
                $this->conn->executeNonQuery($queryDeletePrevious);

                // insert new relations
                $queryRel = $this->buildRelationQuery($entity);
                foreach (explode(";", $queryRel) as $q) {
                    if (strlen($q) > 5)
                        $this->conn->executeInsert($q);
                }
            }
            if ($relation->getCardinality() == Relation::$oneToMany) {
                $relMapper = MapperBuilder::buildFromName($this->mapping, $relation->getEntity());
                $m = "get" . $relation->getName();
                $setid = "set" . $relMapper->getNameForColumn($relation->getForeignColumn());

                // save actual relations
                foreach ($entity->$m() as $relEntity) {
                    $relEntity->$setid($entity->getId());
                    $this->save($relEntity);
                }

                //  delete old relations.
                // TODO: delete old relations
            }
        }
    }
public function updateRelations ( $ entity ) { $ mapper = MapperBuilder :: buildFromMapping ( $ this -> mapping , get_class ( $ entity ) ) ; foreach ( $ mapper -> getRelations ( ) as $ relation ) { if ( $ relation -> getCardinality ( ) == Relation :: $ manyToMany ) { // delete previous relations $ queryDeletePrevious = $ this -> buildDeleteRelationQuery ( $ relation , $ entity ) ; $ this -> conn -> executeNonQuery ( $ queryDeletePrevious ) ; // insert new relations $ queryRel = $ this -> buildRelationQuery ( $ entity ) ; foreach ( explode ( ";" , $ queryRel ) as $ q ) { if ( strlen ( $ q ) > 5 ) $ this -> conn -> executeInsert ( $ q ) ; } } if ( $ relation -> getCardinality ( ) == Relation :: $ oneToMany ) { $ relMapper = MapperBuilder :: buildFromName ( $ this -> mapping , $ relation -> getEntity ( ) ) ; $ m = "get" . $ relation -> getName ( ) ; $ setid = "set" . $ relMapper -> getNameForColumn ( $ relation -> getForeignColumn ( ) ) ; // save actual relations foreach ( $ entity -> $ m ( ) as $ relEntity ) { $ relEntity -> $ setid ( $ entity -> getId ( ) ) ; $ this -> save ( $ relEntity ) ; } //  delete old relations. // TODO: delete old relations } } }
Update the entity relations.

OneToOne o ManyToMany.

@param type $entity
Update the entity relations .