Beispiel #1
0
    /**
     * Create & Update function
     */
    public function create($aData, $aFields = array())
    {
        if (!isset($aData['ADD_TAB_UID']) || (isset($aData['ADD_TAB_UID']) && $aData['ADD_TAB_UID'] == '')) {
            $aData['ADD_TAB_UID'] = G::generateUniqueID();
        }

        $oConnection = Propel::getConnection(AdditionalTablesPeer::DATABASE_NAME);

        try {
            $oAdditionalTables = new AdditionalTables();
            $oAdditionalTables->fromArray($aData, BasePeer::TYPE_FIELDNAME);

            if ($oAdditionalTables->validate()) {
                $oConnection->begin();
                $iResult = $oAdditionalTables->save();
                $oConnection->commit();
                /*                 * **DEPRECATED
                  require_once 'classes/model/ShadowTable.php';
                  $oShadowTable = new ShadowTable();
                  $oShadowTable->create(array('ADD_TAB_UID' => $aData['ADD_TAB_UID'],
                  'SHD_ACTION'  => 'CREATE',
                  'SHD_DETAILS' => serialize($aFields),
                  'USR_UID'     => (isset($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : ''),
                  'APP_UID'     => '',
                  'SHD_DATE'    => date('Y-m-d H:i:s')));
                 */

                $addTabDescription = ($aData["ADD_TAB_DESCRIPTION"] != "")? ", Description: " . $aData["ADD_TAB_DESCRIPTION"] : ".";
                G::auditLog("CreatePmtable", "PM Table Name: " . $aData['ADD_TAB_NAME'] . $addTabDescription);
                return $aData['ADD_TAB_UID'];
            } else {
                $sMessage = '';
                $aValidationFailures = $oAdditionalTables->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);
        }
    }