Skip to content

Commit

Permalink
adding state for dirty columns.
Browse files Browse the repository at this point in the history
  • Loading branch information
padams committed Jan 24, 2022
1 parent 5e89e07 commit 322cf30
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions owa_entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class owa_entity {
var $_tableProperties = array();
var $wasPersisted;
var $cache;
var $dirty = [];

function init() {

Expand Down Expand Up @@ -200,15 +201,39 @@ function setGuid($string) {
function set($name, $value, $filter = true) {

if ( array_key_exists( $name, $this->properties ) ) {

$existing_value = $this->get( $name );

$method = $name.'SetFilter';

if ( $filter && method_exists( $this, $method ) ) {
$this->properties[$name]->setValue( $this->$method( $value ) );
} else {
$this->properties[$name]->setValue( $value );

$value = $this->$method( $value );
}

$this->properties[$name]->setValue( $value );

if ( $existing_value != $value ) {

$this->markDirty( $name, $value );
}

}
}

function markDirty( $name, $value ) {

$this->dirty[$name] = $value;
}

function isDirty() {

if ( ! empty( $this->dirty ) ) {

return true;
}
}

// depricated
function setValues($values) {

Expand Down

0 comments on commit 322cf30

Please sign in to comment.