public function update($columns)
    {
        static::checkReadOnly();

        if ($this->isFresh()) {
            $message = 'Can not update fresh Model: ' . static::class;
            throw new \LogicException($message);
        }

        $this->updateStampColumns($columns);

        $columns = (array) $columns;
        $data = Utils::arrayWhitelist($this->changes, $columns);
        $data = static::validate($data, false);

        $database = self::getDatabase();
        $stmt = $database->update(static::TABLE, $data, $this->getPrimaryKey());

        $error_code = $stmt->errorCode();
        if ($error_code == '00000') {
            $changes = Utils::arrayBlacklist($this->changes, $columns);
            $data = $this->getData();
            $where = Utils::arrayWhitelist($data, static::PRIMARY_KEY);
            if ($this->load($where)) {
                $this->changes = $changes;
                return true;
            }
            return false;
        }
        return $error_code;
    }
public function update($columns)
    {
        static::checkReadOnly();

        if ($this->isFresh()) {
            $message = 'Can not update fresh Model: ' . static::class;
            throw new \LogicException($message);
        }

        $this->updateStampColumns($columns);

        $columns = (array) $columns;
        $data = Utils::arrayWhitelist($this->changes, $columns);
        $data = static::validate($data, false);

        $database = self::getDatabase();
        $stmt = $database->update(static::TABLE, $data, $this->getPrimaryKey());

        $error_code = $stmt->errorCode();
        if ($error_code == '00000') {
            $changes = Utils::arrayBlacklist($this->changes, $columns);
            $data = $this->getData();
            $where = Utils::arrayWhitelist($data, static::PRIMARY_KEY);
            if ($this->load($where)) {
                $this->changes = $changes;
                return true;
            }
            return false;
        }
        return $error_code;
    }
public function update ( $ columns ) { static :: checkReadOnly ( ) ; if ( $ this -> isFresh ( ) ) { $ message = 'Can not update fresh Model: ' . static :: class ; throw new \ LogicException ( $ message ) ; } $ this -> updateStampColumns ( $ columns ) ; $ columns = ( array ) $ columns ; $ data = Utils :: arrayWhitelist ( $ this -> changes , $ columns ) ; $ data = static :: validate ( $ data , false ) ; $ database = self :: getDatabase ( ) ; $ stmt = $ database -> update ( static :: TABLE , $ data , $ this -> getPrimaryKey ( ) ) ; $ error_code = $ stmt -> errorCode ( ) ; if ( $ error_code == '00000' ) { $ changes = Utils :: arrayBlacklist ( $ this -> changes , $ columns ) ; $ data = $ this -> getData ( ) ; $ where = Utils :: arrayWhitelist ( $ data , static :: PRIMARY_KEY ) ; if ( $ this -> load ( $ where ) ) { $ this -> changes = $ changes ; return true ; } return false ; } return $ error_code ; }
Selectively updates the model's row in the Database

@see validate() Throws

@param string|string[] $columns Specify which columns to update

@return true   On success
@return false  On post-update failure
@return string On Database failure @see http://php.net/pdo.errorcode

@throws ReadOnlyModelException @see checkReadOnly()
@throws \LogicException        If trying to update a fresh Model
Selectively updates the model s row in the Database