示例#1
0
 /**
  * Create the application document registry
  *
  * @param array $aData
  * @return string
  */
 public function create($aData)
 {
     $oConnection = Propel::getConnection(GroupUserPeer::DATABASE_NAME);
     try {
         $oGroupUser = new GroupUser();
         $oGroupUser->fromArray($aData, BasePeer::TYPE_FIELDNAME);
         if ($oGroupUser->validate()) {
             $oConnection->begin();
             $iResult = $oGroupUser->save();
             $oConnection->commit();
             return $iResult;
         } else {
             $sMessage = '';
             $aValidationFailures = $oGroupUser->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;
     }
 }