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 and the new object are always going to be different cause when you get the new one, the update_at value always is gonig the be newer than the older, despite the rest of attributes are different or not. So with a getHashCode you could calculate its value by implementing all attributes but not the update_at one, this way you are getting a value just for the columns (attributes) that you consider are important. This way you can compare both old and new objects ignoring the update_at attribute. I have never implemented a getHashCode() method in PHP, but i did in Java, it is some kind of algorithm, so it should be easy (or may be not that hard) to get it working on PHP. Even if PHP objects have a default HashCode, you should override it to get rid off the update_at attribute. 2010/11/14 LeBurt <[email protected]> > 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 Symfony, I'm learning OOP as > well at the same time, which is a bit of a challenge. Having lots of > fun at it though... :) > > Many thanks, > > Burt. > > > On Nov 14, 7:35 pm, Daniel Lohse <[email protected]> wrote: > > 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, at 1:08 AM, LeBurt <[email protected]> wrote: > > > > > > > > > > > > > > > > > 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 in my action: > > > > > $lastUpdate = $this->supplier->getUpdatedAt(); > > > $form->save(); > > > $newUpdate = $this->supplier->getUpdatedAt(); > > > > > if ($lastUpdate != $newUpdate) return 'changes'; > > > else return 'nochanges'; > > > > > Works like a charm and it's simple enough for my needs. > > > > > Thanks all for the inspiration. > > > > > Burt. > > > > > -- > > > If you want to report a vulnerability issue on symfony, please send it > to security at symfony-project.com > > > > > You received this message because you are subscribed to the Google > > > Groups "symfony users" group. > > > To post to this group, send email to [email protected] > > > To unsubscribe from this group, send email to > > > [email protected]<symfony-users%[email protected]> > > > For more options, visit this group at > > >http://groups.google.com/group/symfony-users?hl=en > > -- > If you want to report a vulnerability issue on symfony, please send it to > security at symfony-project.com > > You received this message because you are subscribed to the Google > Groups "symfony users" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected]<symfony-users%[email protected]> > For more options, visit this group at > http://groups.google.com/group/symfony-users?hl=en > -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en
