protected function do_save_as_update() {

		$dirty = $this->get_dirty();

		if ( ! $dirty ) {
			return true;
		}

		if ( static::table() instanceof TimestampedTable ) {
			$this->set_attribute( static::table()->get_updated_at_column(), $this->fresh_timestamp() );
			$dirty = $this->get_dirty();
		}

		$columns = static::table()->get_columns();

		$previous = array();
		$update   = array();

		foreach ( $dirty as $column => $value ) {

			if ( array_key_exists( $column, $this->_original ) ) {
				$previous[ $column ] = $this->_original[ $column ];
			}

			$update[ $column ] = $columns[ $column ]->prepare_for_storage( $value );
		}

		$this->fire_model_event( 'updating', array(
			'changed' => $dirty,
			'from'    => $previous
		) );

		$result = static::make_query_object()->update( $this->get_pk(), $update );

		if ( $result ) {

			if ( static::$_cache ) {
				Cache::update( $this );
			}

			$this->fire_model_event( 'updated', array(
				'changed' => $dirty,
				'from'    => $previous
			) );
		}

		return $result;
	}
protected function do_save_as_update() {

		$dirty = $this->get_dirty();

		if ( ! $dirty ) {
			return true;
		}

		if ( static::table() instanceof TimestampedTable ) {
			$this->set_attribute( static::table()->get_updated_at_column(), $this->fresh_timestamp() );
			$dirty = $this->get_dirty();
		}

		$columns = static::table()->get_columns();

		$previous = array();
		$update   = array();

		foreach ( $dirty as $column => $value ) {

			if ( array_key_exists( $column, $this->_original ) ) {
				$previous[ $column ] = $this->_original[ $column ];
			}

			$update[ $column ] = $columns[ $column ]->prepare_for_storage( $value );
		}

		$this->fire_model_event( 'updating', array(
			'changed' => $dirty,
			'from'    => $previous
		) );

		$result = static::make_query_object()->update( $this->get_pk(), $update );

		if ( $result ) {

			if ( static::$_cache ) {
				Cache::update( $this );
			}

			$this->fire_model_event( 'updated', array(
				'changed' => $dirty,
				'from'    => $previous
			) );
		}

		return $result;
	}
protected function do_save_as_update ( ) { $ dirty = $ this -> get_dirty ( ) ; if ( ! $ dirty ) { return true ; } if ( static :: table ( ) instanceof TimestampedTable ) { $ this -> set_attribute ( static :: table ( ) -> get_updated_at_column ( ) , $ this -> fresh_timestamp ( ) ) ; $ dirty = $ this -> get_dirty ( ) ; } $ columns = static :: table ( ) -> get_columns ( ) ; $ previous = array ( ) ; $ update = array ( ) ; foreach ( $ dirty as $ column => $ value ) { if ( array_key_exists ( $ column , $ this -> _original ) ) { $ previous [ $ column ] = $ this -> _original [ $ column ] ; } $ update [ $ column ] = $ columns [ $ column ] -> prepare_for_storage ( $ value ) ; } $ this -> fire_model_event ( 'updating' , array ( 'changed' => $ dirty , 'from' => $ previous ) ) ; $ result = static :: make_query_object ( ) -> update ( $ this -> get_pk ( ) , $ update ) ; if ( $ result ) { if ( static :: $ _cache ) { Cache :: update ( $ this ) ; } $ this -> fire_model_event ( 'updated' , array ( 'changed' => $ dirty , 'from' => $ previous ) ) ; } return $ result ; }
Save this model as an update query.

@since 2.0

@return bool

@throws Exception
Save this model as an update query .