src/main/php/DataDo/Data/Repository.php
public function update($entity)
    {
        if ($this->idProperty === null) {
            throw new ConfigurationException('No idProperty set');
        }

        $id = $this->idProperty->getValue($entity);

        if ($id === null) {
            throw new ConfigurationException('Value of ' . $this->idProperty->getName() . ' is null');
        }

        $values = $this->getInsertValues($entity, $this->namingContention);
        $keyString = implode(array_keys($values), ' = ?,') . ' = ?';
        $idColumn = $this->namingContention->propertyToColumnName($this->idProperty);
        $onlyValues = array_values($values);
        $onlyValues[] = $id;

        $sql = "UPDATE $this->tableName SET $keyString WHERE $idColumn = ?";
        $sth = $this->pdo->prepare($sql);
        $sth->execute($onlyValues);
        return $id;
    }
public function update($entity)
    {
        if ($this->idProperty === null) {
            throw new ConfigurationException('No idProperty set');
        }

        $id = $this->idProperty->getValue($entity);

        if ($id === null) {
            throw new ConfigurationException('Value of ' . $this->idProperty->getName() . ' is null');
        }

        $values = $this->getInsertValues($entity, $this->namingContention);
        $keyString = implode(array_keys($values), ' = ?,') . ' = ?';
        $idColumn = $this->namingContention->propertyToColumnName($this->idProperty);
        $onlyValues = array_values($values);
        $onlyValues[] = $id;

        $sql = "UPDATE $this->tableName SET $keyString WHERE $idColumn = ?";
        $sth = $this->pdo->prepare($sql);
        $sth->execute($onlyValues);
        return $id;
    }
public function update ( $ entity ) { if ( $ this -> idProperty === null ) { throw new ConfigurationException ( 'No idProperty set' ) ; } $ id = $ this -> idProperty -> getValue ( $ entity ) ; if ( $ id === null ) { throw new ConfigurationException ( 'Value of ' . $ this -> idProperty -> getName ( ) . ' is null' ) ; } $ values = $ this -> getInsertValues ( $ entity , $ this -> namingContention ) ; $ keyString = implode ( array_keys ( $ values ) , ' = ?,' ) . ' = ?' ; $ idColumn = $ this -> namingContention -> propertyToColumnName ( $ this -> idProperty ) ; $ onlyValues = array_values ( $ values ) ; $ onlyValues [ ] = $ id ; $ sql = "UPDATE $this->tableName SET $keyString WHERE $idColumn = ?" ; $ sth = $ this -> pdo -> prepare ( $ sql ) ; $ sth -> execute ( $ onlyValues ) ; return $ id ; }
Update an existing entity in the database.
@param mixed $entity the entity
@return int the id of the entity
@throws ConfigurationException if no idProperty was set
Update an existing entity in the database .