Im not an expert, but I would suggest you to implement a getHashCode()
method for your objects.
What I recall, a hashcode is like a unique number result of a calculation
based on the attributes values and types of a class;
it is like a check sum.
So if you have an updated_at attribute, the old an
Well, I suppose I can live with it for the moment. My ideal solution
would be like this:
$supplier = $form->save();
if ($supplier->isModified()) return 'changes';
else return 'nochange';
but I'm afraid I need more time before I can come up with a solution
to this myself. I'm not just learning Sym
Yes, you can indeed do that — I might have a look at the Timestampable behavior
and see what it does, maybe you'll get some more insights into how you can do
this some other way but if you can live with your solution then that's also
fine. :)
Cheers, Daniel
Sent from my iPad
On Nov 15, 2010,
Well, we can mark this one solved. Daniel's solution seemed simple and
elegant but I couldn't really figure it out with my cuurent level of
knowledge. Then I read Richtermeister's post again and fathomed that
all I'd have to do is add the timestampable behavior on my Doctrine
class and then do this
@Richtermeister:
Good idea, I dumped the serialized objects before and after and they
are indeed different, although not in the updated_at field which I'm
not using. This is what I got:
Before:
string(2636) "C:8:"Supplier":1864:{a:14:{s:3:"_id";a:1:{s:2:"id";i:8;}
s:5:"_data";a:40:{s:2:"id";i:8;
What do you want to do? Before you save the form (and therefore the object),
you can get at the changes like described here:
http://groups.google.com/group/symfony-users/browse_thread/thread/be414f79f499f869/a18b2291ba30275c?lnk=gst&q=doctrine+isModified#a18b2291ba30275c
Just add the doUpdateObj
Hey there,
your first insight is right, you're holding 2 references to the same
object, so it'll always be the same.
In your second case I could only imagine that the updated_at field is
being updated (maybe). To find out, why don't you look at the
serialized strings and see where they differ...
Thanks for the suggestion Gareth. Unfortunately it doesn't work.
Since I'm not all that knowledgeable in OOP, I was thinking this might
have something to do with the $oldstate and $newstate objects being
the same (two references to the same object), that way when you change
one the other changes a