/**
  * updateInstanceData
  * @param string $strType, string $strTypeId, integer $intTypeVersion
  * @author Cornelius Hansjakob <*****@*****.**>
  * @version 1.0
  */
 protected final function updateInstanceData($strType, $strTypeId, $intTypeVersion)
 {
     if (count($this->setup->InstanceFields()) > 0) {
         $intUserId = Zend_Auth::getInstance()->getIdentity()->id;
         $objGenTable = $this->getModelGenericData()->getGenericTable($strType . '-' . $this->setup->getFormId() . '-' . $this->setup->getFormVersion() . '-Instances');
         $arrInstanceData = array('idUsers' => $intUserId, 'changed' => date('Y-m-d H:i:s'));
         /**
          * for each instance field, add to instance data array
          */
         foreach ($this->setup->InstanceFields() as $strField => $objField) {
             if (is_array($objField->getValue())) {
                 $arrInstanceData[$strField] = json_encode($objField->getValue());
             } else {
                 $arrInstanceData[$strField] = $objField->getValue();
             }
         }
         $strWhere = $objGenTable->getAdapter()->quoteInto($strType . 'Id = ?', $strTypeId);
         $strWhere .= $objGenTable->getAdapter()->quoteInto(' AND version = ?', $intTypeVersion);
         $strWhere .= $objGenTable->getAdapter()->quoteInto(' AND idLanguages = ?', $this->setup->getLanguageId());
         $intNumOfEffectedRows = $objGenTable->update($arrInstanceData, $strWhere);
         if ($intNumOfEffectedRows == 0) {
             $this->insertInstanceData($strType, array('Id' => $strTypeId, 'Version' => $intTypeVersion));
         }
     }
 }
 /**
  * loadInstanceData
  * @param string $strType
  * @param array $arrTypeProperties
  * @author Thomas Schedler <*****@*****.**>
  * @version 1.0
  */
 protected final function loadInstanceData($strType, $arrTypeProperties)
 {
     try {
         /**
          * generic form instance fields
          */
         if (count($this->setup->InstanceFields()) > 0) {
             $objGenTable = $this->getModelGenericData()->getGenericTable($strType . '-' . $this->setup->getFormId() . '-' . $this->setup->getFormVersion() . '-Instances');
             $objSelect = $objGenTable->select();
             $arrSelectFields = array();
             /**
              * for each instance field, add to select array data array
              */
             foreach ($this->setup->InstanceFields() as $strField => $objField) {
                 $arrSelectFields[] = $strField;
             }
             $objSelect->from($objGenTable->info(Zend_Db_Table_Abstract::NAME), $arrSelectFields);
             $objSelect->where($strType . 'Id = ?', $arrTypeProperties['Id']);
             $objSelect->where('version = ?', $arrTypeProperties['Version']);
             $objSelect->where('idLanguages = ?', $this->Setup()->getLanguageId());
             $arrGenFormsData = $objGenTable->fetchAll($objSelect)->toArray();
             if (count($arrGenFormsData) > 0) {
                 $this->blnHasLoadedInstanceData = true;
                 foreach ($arrGenFormsData as $arrRowGenFormData) {
                     foreach ($arrRowGenFormData as $column => $value) {
                         if (is_array(json_decode($value))) {
                             $this->setup->getInstanceField($column)->setValue(json_decode($value));
                         } else {
                             $this->setup->getInstanceField($column)->setValue($value);
                         }
                     }
                 }
             }
         }
     } catch (Exception $exc) {
         $this->core->logger->err($exc);
     }
 }
 /**
  * compareGenericFieldValues
  * @author Thomas Schedler <*****@*****.**>
  * @version 1.0
  */
 public function compareGenericFieldValues(GenericSetup &$objGenericSetup)
 {
     $this->core->logger->debug('massiveart->generic->data->GenericData->compareGenericFieldValues()');
     try {
         if (count($objGenericSetup->CoreFields()) > 0) {
             /**
              * for each core field, try to get the "old" value
              */
             foreach ($objGenericSetup->CoreFields() as $strField => $objField) {
                 if (!is_null($this->setup->getCoreField($strField))) {
                     $objField->setValue($this->setup->getCoreField($strField)->getValue());
                 }
             }
         }
         if (count($objGenericSetup->FileFields()) > 0) {
             /**
              * for each file field, try to get the "old" value
              */
             foreach ($objGenericSetup->FileFields() as $strField => $objField) {
                 if (!is_null($this->setup->getFileField($strField))) {
                     $objField->setValue($this->setup->getFileField($strField)->getValue());
                 }
             }
         }
         if (count($objGenericSetup->InstanceFields()) > 0) {
             /**
              * for each instance field, try to get the "old" values
              */
             foreach ($objGenericSetup->InstanceFields() as $strField => $objField) {
                 if (!is_null($this->setup->getInstanceField($strField))) {
                     $objField->setValue($this->setup->getInstanceField($strField)->getValue());
                 }
             }
         }
         // TODO : compare special fields
     } catch (Exception $exc) {
         $this->core->logger->err($exc);
     }
 }