We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Modified or before value in model

In rails there is a notion of modified? value if the record is modified.

I donĀ“t find any reference in documentation to acess before values (was in rails).

i can add this with afterFetch keep value and check in beforesave to know if value has change. is there any other solution ?



7.9k
edited Apr '14

I didn't see it before, but this is the functionnality i need.

In the documentation, i can't see how get before values, i can only check if the value has change. I find this in C files : getSnapshotData but it's missing in the documentation

And i have a bug, i use it like this

class Product extends Phalcon\Mvc\Model {
  public function initialize(){
    $this->keepSnapshots(true);
  }
  public function afterSave(){
    print_r($this->getChangedFields());
    exit();
  }
}

And i get many fields of other model, not only the product model.