Esempio n. 1
0
 /**
  * Exchange the rank of the object with the one passed as argument, and saves both objects
  *
  * @param     ChildWork $object
  * @param     ConnectionInterface $con optional connection
  *
  * @return    $this|ChildWork the current object
  *
  * @throws Exception if the database cannot execute the two updates
  */
 public function swapWith($object, ConnectionInterface $con = null)
 {
     if (null === $con) {
         $con = Propel::getServiceContainer()->getWriteConnection(WorkTableMap::DATABASE_NAME);
     }
     $con->transaction(function () use($con, $object) {
         $oldRank = $this->getSortableRank();
         $newRank = $object->getSortableRank();
         $this->setSortableRank($newRank);
         $object->setSortableRank($oldRank);
         $this->save($con);
         $object->save($con);
     });
     return $this;
 }