'That was *wouldn't* be possible to overload ....' On Jan 11, 9:05 pm, Dennis <gear...@sbcglobal.net> wrote: > On further investigation, I was trying to do two statements at the > same time, set the isolation level to SERIALIZABLE and start the > transaction. I was actually naming the transaction as a setpoint to > the name SERIALIZALBLE. > > Leaving the name blank, i.e. $connection->beginTransaction() still > didn't work. > > Any ideas guys and gals? > > I REALLY would like the schema + object_class + file_widget to take > care of it all. Symfony's pretty powerful, maybe it does. I haven't > been able to do that yet. So I"m doing a lot manually that probably > could be done automagically. But still, it's an interesting question > and must have other applications. > > It would be possible to overload every class's methods to put every > other classes methods in a common transaction. It'd be nice to be able > to just set the object to NO TRANSACTION and set an external > transaction. > > Eventually, I'll dig into the code, but it would mean a hack. > > On Jan 11, 5:31 pm, Dennis <gear...@sbcglobal.net> wrote: > > > (posted on symfony forums: general, 1.3/1.4 branch) > > How can I put several updates of objects inside of one transaction in > > Symfony? > > > For example: > > > I have a car object which is allowed only one picture. The owner of > > the record edits the record about the car and supplies the name of > > another file foto (uploaded on a different page). S/he also updates > > some textual information. > > > So: > > > change outgoing photo's 'deleted_timestamp' field to a date from NULL > > change incoming photo photo's NULL 'car_id' to edited car object's id > > update the car object. > > > It works with no transaction around them, but 'with no transaction' > > obviously. The only relevant database constraint is that the photo's > > records' 'car_id' is a foreign key to car table and it's set to ON > > DELETE CASCADE to get rid of the photos. Each car can have only one > > photo, but the photos' records are made 'deleted' so that a garbage > > collection system deletes the actual files on the hard drive. This is > > because it's not possible to put a file deletion in a transaction > > Smile [I know I could either move it or rename it with a suffix or > > prefix, but I'm also trying to learn about symfony and transactions.) > > > The way I'm trying it below doesn't work. I don't get any exceptions, > > warnings, or error messages. > > ---------------------------------------: > > (LOTS of error checking taken out) > > (This is in the car's action file update action) > > > $context=$this->getContext(); > > $connection = $context->getDatabaseConnection('doctrine'); > > try{ > > $connection->beginTransaction('SERIALIZABLE'); > > > $this->currentMediaObject['deleted_tz'] = date('Y-m-d > > H:i:s'); > > $this->currentMediaObject->save(); > > > $this->incomingMediaObject['car_id'] = > > $this->carForm->getValue('id'); > > > $this->incomingMediaObject->save(); > > > $this->Carform->save(); > > $connection->commit(); > >
-- You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-us...@googlegroups.com. To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en.