コード例 #1
0
ファイル: ProcessUser.php プロジェクト: nshong/processmaker
 public function create($aData)
 {
     $oConnection = Propel::getConnection(ProcessUserPeer::DATABASE_NAME);
     try {
         $criteria = new Criteria('workflow');
         $criteria->add(ProcessUserPeer::PU_UID, $aData['PU_UID']);
         $criteria->add(ProcessUserPeer::PRO_UID, $aData['PRO_UID']);
         $criteria->add(ProcessUserPeer::USR_UID, $aData['USR_UID']);
         $criteria->add(ProcessUserPeer::PU_TYPE, $aData['PU_TYPE']);
         $objects = ProcessUserPeer::doSelect($criteria, $oConnection);
         $oConnection->begin();
         foreach ($objects as $row) {
             $this->remove($row->getTasUid(), $row->getUsrUid(), $row->getTuType(), $row->getTuRelation());
         }
         $oConnection->commit();
         $oProcessUser = new ProcessUser();
         $oProcessUser->fromArray($aData, BasePeer::TYPE_FIELDNAME);
         if ($oProcessUser->validate()) {
             $oConnection->begin();
             $iResult = $oProcessUser->save();
             $oConnection->commit();
             return $iResult;
         } else {
             $sMessage = '';
             $aValidationFailures = $oProcessUser->getValidationFailures();
             foreach ($aValidationFailures as $oValidationFailure) {
                 $sMessage .= $oValidationFailure->getMessage() . '<br />';
             }
             throw new Exception('The registry cannot be created!<br />' . $sMessage);
         }
     } catch (Exception $oError) {
         $oConnection->rollback();
         throw $oError;
     }
 }
コード例 #2
0
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      Connection $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *       rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria();
         $criteria->add(ProcessUserPeer::PU_UID, $pks, Criteria::IN);
         $objs = ProcessUserPeer::doSelect($criteria, $con);
     }
     return $objs;
 }