Thanks for your reply, but I already know that the object has been modified,
what I want to do is check if a specific field has changed, and retrieve the
old value. I thought that I could do this using the getModified() method
before saving the new values, but it gives me the new value.
I need to fetch the value currently stored in the database, but if I use a
Doctrine query inside the preSave() method, I get a white screen (even in
dev environment, no error details).
I believe that what I'm trying to do is not that strange, there has to be
someway to achieve that.
Nacho
http://card.ly/nachocual
2009/10/6 Andrei Dziahel trickster...@gmail.com
Hi.
Use
isModifiedhttp://www.doctrine-project.org/Doctrine_Record/1_0#method_ismodifiedmethod.
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
-~--~~~~--~~--~--~---