Beispiel #1
0
 public function update($aData)
 {
     $con = Propel::getConnection(AppThreadPeer::DATABASE_NAME);
     try {
         $con->begin();
         $oApp = AppThreadPeer::retrieveByPK($aData['APP_UID'], $aData['APP_THREAD_INDEX']);
         if (is_object($oApp) && get_class($oApp) == 'AppThread') {
             $oApp->fromArray($aData, BasePeer::TYPE_FIELDNAME);
             if ($oApp->validate()) {
                 $res = $oApp->save();
                 $con->commit();
                 return $res;
             } else {
                 $msg = '';
                 foreach ($this->getValidationFailures() as $objValidationFailure) {
                     $msg .= $objValidationFailure->getMessage() . "<br/>";
                 }
                 throw new PropelException('The AppThread row cannot be created!', new PropelException($msg));
             }
         } else {
             $con->rollback();
             throw new Exception("This AppThread row doesn't exist!");
         }
     } catch (Exception $oError) {
         throw $oError;
     }
 }
Beispiel #2
0
 /**
  * Implementation for 'DELETE' method for Rest API
  *
  * @param  mixed $appUid, $appThreadIndex Primary key
  *
  * @return array $result Returns array within multiple records or a single record depending if
  *                       a single selection was requested passing id(s) as param
  */
 protected function delete($appUid, $appThreadIndex)
 {
     $conn = Propel::getConnection(AppThreadPeer::DATABASE_NAME);
     try {
         $conn->begin();
         $obj = AppThreadPeer::retrieveByPK($appUid, $appThreadIndex);
         if (!is_object($obj)) {
             throw new RestException(412, 'Record does not exist.');
         }
         $obj->delete();
         $conn->commit();
     } catch (Exception $e) {
         $conn->rollback();
         throw new RestException(412, $e->getMessage());
     }
 }