On Sunday, April 06, 2008, Chris wrote:
> Thanks for the advice, I was actually leaning towards looking into
> behaviors a little more. But basically I need to do more with the
> data when it is actually first loaded into the object, not upon the
> save. Seems like everything I have found thus far deals with the
> object later in the life cycle like the save etc. and not when the
> object is first initialized. All I'm looking for is a callback that
> can be called when the object is first initialized by using the
> hydrate function etc.
If you wish to know when the object is being created (a INSERT SQL), use a
behavior to bind to the ->save() method and wrap the code in an ->isNew()
block. Like so:
public function handleSave($obj)
{
if ($obj->isNew())
{
// handle new object (INSERT)
}
else
{
// handle old object (UPDATE)
}
}
Carl
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony developers" 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-devs?hl=en
-~----------~----~----~----~------~----~------~--~---