コード例 #1
0
ファイル: BaseStore.php プロジェクト: peterAK/pgs-sts
 /**
  * Exchange the rank of the object with the one passed as argument, and saves both objects
  *
  * @param     Store $object
  * @param     PropelPDO $con optional connection
  *
  * @return    Store the current object
  *
  * @throws Exception if the database cannot execute the two updates
  */
 public function swapWith($object, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(StorePeer::DATABASE_NAME);
     }
     $con->beginTransaction();
     try {
         $oldRank = $this->getSortableRank();
         $newRank = $object->getSortableRank();
         $this->setSortableRank($newRank);
         $this->save($con);
         $object->setSortableRank($oldRank);
         $object->save($con);
         $con->commit();
         return $this;
     } catch (Exception $e) {
         $con->rollback();
         throw $e;
     }
 }