示例#1
0
 /**
  * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
  * feature (like MySQL or SQLite).
  *
  * This method is not very speedy because it must perform a query first to get
  * the implicated records and then perform the deletes by calling those Peer classes.
  *
  * This method should be used within a transaction if possible.
  *
  * @param      Criteria $criteria
  * @param      PropelPDO $con
  * @return int The number of affected rows (if supported by underlying database driver).
  */
 protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
 {
     // initialize var to track total num of affected rows
     $affectedRows = 0;
     // first find the objects that are implicated by the $criteria
     $objects = AccountPeer::doSelect($criteria, $con);
     foreach ($objects as $obj) {
         // delete related BookingType objects
         $criteria = new Criteria(BookingTypePeer::DATABASE_NAME);
         $criteria->add(BookingTypePeer::ACCOUNT_ID, $obj->getId());
         $affectedRows += BookingTypePeer::doDelete($criteria, $con);
         // delete related ClockingType objects
         $criteria = new Criteria(ClockingTypePeer::DATABASE_NAME);
         $criteria->add(ClockingTypePeer::ACCOUNT_ID, $obj->getId());
         $affectedRows += ClockingTypePeer::doDelete($criteria, $con);
         // delete related Domain objects
         $criteria = new Criteria(DomainPeer::DATABASE_NAME);
         $criteria->add(DomainPeer::ACCOUNT_ID, $obj->getId());
         $affectedRows += DomainPeer::doDelete($criteria, $con);
         // delete related Holiday objects
         $criteria = new Criteria(HolidayPeer::DATABASE_NAME);
         $criteria->add(HolidayPeer::ACCOUNT_ID, $obj->getId());
         $affectedRows += HolidayPeer::doDelete($criteria, $con);
         // delete related Plugin objects
         $criteria = new Criteria(PluginPeer::DATABASE_NAME);
         $criteria->add(PluginPeer::ACCOUNT_ID, $obj->getId());
         $affectedRows += PluginPeer::doDelete($criteria, $con);
         // delete related Property objects
         $criteria = new Criteria(PropertyPeer::DATABASE_NAME);
         $criteria->add(PropertyPeer::ACCOUNT_ID, $obj->getId());
         $affectedRows += PropertyPeer::doDelete($criteria, $con);
         // delete related User objects
         $criteria = new Criteria(UserPeer::DATABASE_NAME);
         $criteria->add(UserPeer::ACCOUNT_ID, $obj->getId());
         $affectedRows += UserPeer::doDelete($criteria, $con);
     }
     return $affectedRows;
 }