Esempio n. 1
0
 public static function doDelete($values, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(UsuarioPermisoPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     if ($values instanceof Criteria) {
         UsuarioPermisoPeer::clearInstancePool();
         $criteria = clone $values;
     } elseif ($values instanceof UsuarioPermiso) {
         UsuarioPermisoPeer::removeInstanceFromPool($values);
         $criteria = $values->buildPkeyCriteria();
     } else {
         $criteria = new Criteria(self::DATABASE_NAME);
         if (count($values) == count($values, COUNT_RECURSIVE)) {
             $values = array($values);
         }
         foreach ($values as $value) {
             $criterion = $criteria->getNewCriterion(UsuarioPermisoPeer::FK_USUARIO_ID, $value[0]);
             $criterion->addAnd($criteria->getNewCriterion(UsuarioPermisoPeer::FK_PERMISO_ID, $value[1]));
             $criteria->addOr($criterion);
             UsuarioPermisoPeer::removeInstanceFromPool($value);
         }
     }
     $criteria->setDbName(self::DATABASE_NAME);
     $affectedRows = 0;
     try {
         $con->beginTransaction();
         $affectedRows += BasePeer::doDelete($criteria, $con);
         $con->commit();
         return $affectedRows;
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
 }
Esempio n. 2
0
 public static function doDelete($values, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(PermisoPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     if ($values instanceof Criteria) {
         PermisoPeer::clearInstancePool();
         $criteria = clone $values;
     } elseif ($values instanceof Permiso) {
         PermisoPeer::removeInstanceFromPool($values);
         $criteria = $values->buildPkeyCriteria();
     } else {
         $criteria = new Criteria(self::DATABASE_NAME);
         $criteria->add(PermisoPeer::ID, (array) $values, Criteria::IN);
         foreach ((array) $values as $singleval) {
             PermisoPeer::removeInstanceFromPool($singleval);
         }
     }
     $criteria->setDbName(self::DATABASE_NAME);
     $affectedRows = 0;
     try {
         $con->beginTransaction();
         $affectedRows += BasePeer::doDelete($criteria, $con);
         UsuarioPermisoPeer::clearInstancePool();
         $con->commit();
         return $affectedRows;
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
 }