Thanks for clarifying :-) Richtermeister wrote: > Hi all, > > as far as I can see none of these explanations are 100% accurate. > If I go with the previous example, the issue is that the $book -> save > () call automatically issues a call to $author -> save(). > This in turn WOULD issue a call to $book -> save() and you'd have a > neverending back & forth. > So the alreadyInSave flag is set on the book, so that when author > calls save on the book, the call is ignored. After the entire savings > procedure is done, the flag is reset. Makes sense? > This has nothing to do with ajax, as separate requests would be > executed in separate threads and wouldn't have access to the very same > object. > Also, the save() call is not executed when no field has changed, but > this is only tracked through an array of changed fields in every > propel object, which is emptied whenever a successful save() executes. > > Hope this helps. > Daniel > > > > > On Mar 6, 10:28 pm, Ant Cunningham <[email protected]> > wrote: >> 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 -~----------~----~----~----~------~----~------~--~---
