Hi.

Use 
isModified<http://www.doctrine-project.org/Doctrine_Record/1_0#method_ismodified>method.

2009/10/2 Ignacio Bergmann <nachoc...@gmail.com>

> Hello, this is my first message to the list... hope it isn't a silly
> question.
>
> I'm using Doctrine, and I have a class in my model which has a field that
> stores the name of a file (a picture).
>
> I have automated the deletion of those files when the corresponding record
> is delete using the postDelete method.
>
> Now, I want to automate the deletion of old files when they are changed for
> a new one. For this I was trying to use preSave and postSave methods, but I
> need to know if the 'file' field of my object is different of the one stored
> in the database.
>
> I have tried using the getModified method, but it gives me the new value of
> the field, instead of the old one. Also, the getLastModified method that the
> Doctrine documentatios suggests doesn't exist.
>
> I'm trying to implement this in the class definition of the object instead
> of implementing it on the form definition file, I think this is were this
> kind of task belong, but I might be wrong (I made it work overriding the
> doSave method of the form, but I still want to move it to the class).
>
> I'm open to suggestions. Thanks,
>
> Nacho
> http://card.ly/nachocual
>
>
>
> My code (that doesn't work):
>
> class Mascotas extends BaseMascotas
> {
>   var $cambios;
>   public function preSave($event)
>   {
>     $this->cambios = $event->getInvoker()->getModified(true);
>   }
>
>   public function postSave($event)
>   {
>     if($this->cambios['foto1'])
>       {
>         $this->deletePictures($this->cambios['foto1']);
>       }
>   }
> }
>
> >
>


-- 
With the best regards, Andy.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to