public function update(\Berthe\VO $object)
    {
        $this->validateTableAndIdentityColumn();

        $mappings = $this->getSaveMappings();

        if (empty($mappings)) {
            $mappings = $this->getDefaultMappings($object);
        }

        $clauseElements = array();
        $params = array();

        $values = $object->__toArray();

        foreach ($mappings as $column => $property) {
            $escape = $this->escapeCharacter;
            $clauseElements[] = sprintf('%s%s%s = %%s', $escape, $column, $escape);
            if (in_array($property, $object->getTranslatableFields())) {
                $value = $object->getAttribute($property);
            } else {
                $value = $values[$property];
            }
            $params[$column] = $value;

            if ($value instanceof \Berthe\Translation\Translation) {
                $this->translator->saveTranslation($value);
            }
        }

        $params['identity'] = $object->getId();

        $columnAssignment = implode(', ', $clauseElements);

        $query = <<<EOQ
UPDATE {$this->getTableName()} SET {$columnAssignment}
WHERE {$this->escapeCharacter}{$this->identityColumn}{$this->escapeCharacter} = %s;
EOQ;

        return (bool)$this->db->query($query, $params);
    }
public function update(\Berthe\VO $object)
    {
        $this->validateTableAndIdentityColumn();

        $mappings = $this->getSaveMappings();

        if (empty($mappings)) {
            $mappings = $this->getDefaultMappings($object);
        }

        $clauseElements = array();
        $params = array();

        $values = $object->__toArray();

        foreach ($mappings as $column => $property) {
            $escape = $this->escapeCharacter;
            $clauseElements[] = sprintf('%s%s%s = %%s', $escape, $column, $escape);
            if (in_array($property, $object->getTranslatableFields())) {
                $value = $object->getAttribute($property);
            } else {
                $value = $values[$property];
            }
            $params[$column] = $value;

            if ($value instanceof \Berthe\Translation\Translation) {
                $this->translator->saveTranslation($value);
            }
        }

        $params['identity'] = $object->getId();

        $columnAssignment = implode(', ', $clauseElements);

        $query = <<<EOQ
UPDATE {$this->getTableName()} SET {$columnAssignment}
WHERE {$this->escapeCharacter}{$this->identityColumn}{$this->escapeCharacter} = %s;
EOQ;

        return (bool)$this->db->query($query, $params);
    }
public function update ( \ Berthe \ VO $ object ) { $ this -> validateTableAndIdentityColumn ( ) ; $ mappings = $ this -> getSaveMappings ( ) ; if ( empty ( $ mappings ) ) { $ mappings = $ this -> getDefaultMappings ( $ object ) ; } $ clauseElements = array ( ) ; $ params = array ( ) ; $ values = $ object -> __toArray ( ) ; foreach ( $ mappings as $ column => $ property ) { $ escape = $ this -> escapeCharacter ; $ clauseElements [ ] = sprintf ( '%s%s%s = %%s' , $ escape , $ column , $ escape ) ; if ( in_array ( $ property , $ object -> getTranslatableFields ( ) ) ) { $ value = $ object -> getAttribute ( $ property ) ; } else { $ value = $ values [ $ property ] ; } $ params [ $ column ] = $ value ; if ( $ value instanceof \ Berthe \ Translation \ Translation ) { $ this -> translator -> saveTranslation ( $ value ) ; } } $ params [ 'identity' ] = $ object -> getId ( ) ; $ columnAssignment = implode ( ', ' , $ clauseElements ) ; $ query =  <<<EOQ
UPDATE {$this->getTableName()} SET {$columnAssignment}
WHERE {$this->escapeCharacter}{$this->identityColumn}{$this->escapeCharacter} = %s;
EOQ ; return ( bool ) $ this -> db -> query ( $ query , $ params ) ; }
Update the object in database
@param \Berthe\VO $object the object to insert
@return boolean
Update the object in database