Beforesave Vs Setter In Activerecord

Hi,

I need some suggestions with this issue: I have an XML with information (properties) that I need to parse and store in a database. The thing is that some properties need to be processed (modified) before being saved in the database.

My doubt is where to perform the modifications to the data.

One solution I figured is to add this method to my Model:




public function __set($name, $value)

    {

            $setter='set'.$name;

            if(method_exists($this,$setter))

                    return $this->$setter($value);


            return parent::__set($name, $value);

    }



This allows to use setters for the properties where I need to make the modifications. It is working fine, but I read its not recommended to override this functions.

The other solution is to make the modifications in AciveRecord beforeSave method.

Which alternative you would recommend? If there is another/better way, please advice.

Thanks in advance!!