If you have neste objects. For example:
Assume the following Schema:
author:
id:
name:
book:
id:
title:
author_id:
So if we do:
$author = new Author();
$author->setName('Lawrence Krubner');
$book = new Book();
$book->setTitle('Learning Symfony');
$book->setAuthor($author);
$book->save();
$author->save();
Calling book save is going to save both the Book and any related object
that has been hyrdated/set and has been modified or is new. so by
checking if an object is already in save we prevent having to save the
object agian if nothing has changed in the instance - so the
$author->save() call above is essentially ignored because the instance
was already saved by the preceding $book->save() call and hasnt been
modified again.
Lawrence Krubner wrote:
>
>
> On Mar 2, 12:38 pm, vadim <[email protected]> wrote:
>> It's a variable showing that the save/update operation already started
>> for this object, so it prevents an implementation of other insert/
>> update operations until the current one is over. When the operation
>> starts - alreadyInSave is turned to true. When it is over -
>> alreadyInSave is turned to false. Just watch the code and let our
>> imagination fly like a songbird :)
>
>
> This is maybe for Ajax? Most PHP code is procedural and runs as a
> single thread, a straight line through the code, one thing after
> another. Two processes competing for the same method happens when?
>
>
>
>> On Mar 2, 6:06 pm, alvaro <[email protected]> wrote:
>>
>>> Maybe you can ask in the propel mailing list?
>>> On Mar 2, 2009, at 11:00 PM, Andrei Dziahel wrote:
>>>> Hi.
>>>> I don't remember exactly since I've left Propel some time ago, but
>>>> AFAIR there's explanation in comments. Just enable them in your
>>>> propel.ini and rebuild model.
>>>> On Mon, Mar 2, 2009 at 07:42, LawrenceKrubner
>>>> <[email protected]> wrote:
>>>> I'm examining some auto-generated code in the Base class of one of
>>>> my model classes. I'm curious about the line with the $this-
>>>>> alreadyInSave. It is first set to true, and then later it is set to
>>>> false. As near as I can see, it is always set to true, and then
>>>> false. What is the point of this? If PHP was asynchronous, this
>>>> would make more sense, but PHP is procedural. Does this boolean flag
>>>> exist for dealing with Ajax requests?
>>>> protected function doSave($con)
>>>> {
>>>> $affectedRows = 0;
>>>> if (!$this->alreadyInSave) {
>>>> $this->alreadyInSave = true;
>>>> if ($this->isModified()) {
>>>> if ($this->isNew()) {
>>>> $pk =
>>>> NewNewsPeer::doInsert($this, $con);
>>>> $affectedRows += 1;
>>>> $this->setId($pk);
>>>> $this->setNew(false);
>>>> } else {
>>>> $affectedRows +=
>>>> NewNewsPeer::doUpdate($this, $con);
>>>> }
>>>> $this->resetModified();
>>>> }
>>>> $this->alreadyInSave = false;
>>>> }
>>>> return $affectedRows;
>>>> }
>>>> --
>>>> 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 [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
-~----------~----~----~----~------~----~------~--~---