当前位置: 首页>>代码示例>>PHP>>正文


PHP CustomField::GetDatabase方法代码示例

本文整理汇总了PHP中CustomField::GetDatabase方法的典型用法代码示例。如果您正苦于以下问题:PHP CustomField::GetDatabase方法的具体用法?PHP CustomField::GetDatabase怎么用?PHP CustomField::GetDatabase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CustomField的用法示例。


在下文中一共展示了CustomField::GetDatabase方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: btnNext_Click


//.........这里部分代码省略.........
                             }
                             $strMobilePhone = "";
                             if (isset($this->intMobilePhoneKey)) {
                                 if (trim($strRowArray[$this->intMobilePhoneKey])) {
                                     $strMobilePhone = trim($strRowArray[$this->intMobilePhoneKey]);
                                 } else {
                                     $strMobilePhone = isset($this->txtMapDefaultValueArray[$this->intMobilePhoneKey]) ? trim($this->txtMapDefaultValueArray[$this->intMobilePhoneKey]->Text) : '';
                                 }
                             }
                             $strFax = "";
                             if (isset($this->intFaxKey)) {
                                 if (trim($strRowArray[$this->intFaxKey])) {
                                     $strFax = trim($strRowArray[$this->intFaxKey]);
                                 } else {
                                     $strFax = isset($this->txtMapDefaultValueArray[$this->intFaxKey]) ? trim($this->txtMapDefaultValueArray[$this->intFaxKey]->Text) : '';
                                 }
                             }
                             $strTitle = "";
                             if (isset($this->intTitleKey)) {
                                 if (trim($strRowArray[$this->intTitleKey])) {
                                     $strTitle = trim($strRowArray[$this->intTitleKey]);
                                 } else {
                                     $strTitle = isset($this->txtMapDefaultValueArray[$this->intTitleKey]) ? trim($this->txtMapDefaultValueArray[$this->intTitleKey]->Text) : '';
                                 }
                             }
                             $strCFVArray = array();
                             $blnCheckCFVError = false;
                             // Custom Field import
                             foreach ($arrItemCustomField as $objCustomField) {
                                 if ($objCustomField->CustomFieldQtypeId != 2) {
                                     $strShortDescription = trim($strRowArray[$intItemCustomFieldKeyArray[$objCustomField->CustomFieldId]]) ? addslashes(trim($strRowArray[$intItemCustomFieldKeyArray[$objCustomField->CustomFieldId]])) : addslashes($this->txtMapDefaultValueArray[$intItemCustomFieldKeyArray[$objCustomField->CustomFieldId]]->Text);
                                     $strCFVArray[$objCustomField->CustomFieldId] = $strShortDescription ? sprintf("'%s'", $strShortDescription) : "NULL";
                                 } else {
                                     $objDatabase = CustomField::GetDatabase();
                                     $strShortDescription = addslashes(trim($strRowArray[$intItemCustomFieldKeyArray[$objCustomField->CustomFieldId]]));
                                     $blnInList = false;
                                     foreach (CustomFieldValue::LoadArrayByCustomFieldId($objCustomField->CustomFieldId) as $objCustomFieldValue) {
                                         if (strtolower($objCustomFieldValue->ShortDescription) == strtolower($strShortDescription)) {
                                             $blnInList = true;
                                             break;
                                         }
                                     }
                                     // Add the CustomFieldValue
                                     /*if (!$blnInList && !in_array($strShortDescription, $strAddedCFVArray)) {
                                     			$strQuery = sprintf("INSERT INTO custom_field_value (custom_field_id, short_description, created_by, creation_date) VALUES (%s, '%s', %s, NOW());", $objCustomField->CustomFieldId, $strShortDescription, $_SESSION['intUserAccountId']);
                                     			$objDatabase->NonQuery($strQuery);
                                     			$strAddedCFVArray[] = $strShortDescription;
                                     		}
                                     		else*/
                                     if (!$blnInList && $this->lstMapDefaultValueArray[$intItemCustomFieldKeyArray[$objCustomField->CustomFieldId]]->SelectedValue != null) {
                                         $strShortDescription = $this->lstMapDefaultValueArray[$intItemCustomFieldKeyArray[$objCustomField->CustomFieldId]]->SelectedName;
                                     } elseif (!$blnInList) {
                                         $blnCheckCFVError = true;
                                         break;
                                     }
                                     if (!$blnCheckCFVError) {
                                         if ($strShortDescription) {
                                             $strCFVArray[$objCustomField->CustomFieldId] = sprintf("'%s'", $strShortDescription);
                                         } else {
                                             $strCFVArray[$objCustomField->CustomFieldId] = "NULL";
                                         }
                                     }
                                 }
                             }
                             if (!$blnCheckCFVError) {
                                 if (isset($strCFVArray) && count($strCFVArray)) {
开发者ID:proxymoron,项目名称:tracmor,代码行数:67,代码来源:contact_import.php

示例2: btnNext_Click


//.........这里部分代码省略.........
                 $objNewLocation->Save();
                 $this->objNewLocationArray[$objNewLocation->LocationId] = $objNewLocation->ShortDescription;
             }
             $this->objNewLocationArray = array();
             $this->objNewCategoryArray = array();
             $this->objNewManufacturerArray = array();
             $this->objNewAssetModelArray = array();
             $this->strModelValuesArray = array();
             $this->blnImportEnd = false;
             $j = 1;
             $strLocationValuesArray = array();
             // Add all unique locations in database
             foreach ($this->strFilePathArray as $strFilePath) {
                 $this->FileCsvData->load($strFilePath);
                 if ($j != 1) {
                     //$this->FileCsvData->appendRow($this->FileCsvData->getHeaders());
                 }
                 // Location Import
                 for ($i = 0; $i < $this->FileCsvData->countRows(); $i++) {
                     $strRowArray = $this->FileCsvData->getRow($i);
                     if (trim($strRowArray[$this->intLocationKey]) && !$this->in_array_nocase(trim($strRowArray[$this->intLocationKey]), $strLocationArray)) {
                         $strLocationArray[] = trim($strRowArray[$this->intLocationKey]);
                         /*$objNewLocation = new Location();
                           $objNewLocation->ShortDescription = addslashes(trim($strRowArray[$this->intLocationKey]));
                           $objNewLocation->Save();*/
                         $strLocationValuesArray[] = sprintf("('%s', '%s', NOW())", addslashes(trim($strRowArray[$this->intLocationKey])), $_SESSION['intUserAccountId']);
                         $strNewLocation[] = addslashes(trim($strRowArray[$this->intLocationKey]));
                         //$this->objNewLocationArray[$objNewLocation->LocationId] = $objNewLocation->ShortDescription;
                     }
                 }
                 $j++;
             }
             if (count($strLocationValuesArray)) {
                 $objDatabase = Location::GetDatabase();
                 $objDatabase->NonQuery(sprintf("INSERT INTO `location` (`short_description`, `created_by`, `creation_date`) VALUES %s;", implode(", ", $strLocationValuesArray)));
                 $intStartId = $objDatabase->InsertId();
                 for ($i = 0; $i < count($strNewLocation); $i++) {
                     $this->objNewLocationArray[$intStartId + $i] = $strNewLocation[$i];
                 }
             }
             $this->btnNext->RemoveAllActions('onclick');
             // Add new ajax actions for button
             $this->btnNext->AddAction(new QClickEvent(), new QAjaxAction('btnNext_Click'));
             $this->btnNext->AddAction(new QClickEvent(), new QToggleEnableAction($this->btnNext));
             $this->btnNext->AddAction(new QEnterKeyEvent(), new QAjaxAction('btnNext_Click'));
             $this->btnNext->AddAction(new QEnterKeyEvent(), new QToggleEnableAction($this->btnNext));
             $this->btnNext->AddAction(new QEnterKeyEvent(), new QTerminateAction());
             $this->btnNext->Warning = "Locations have been imported. Please wait...";
             $this->intImportStep = 2;
             $this->intCurrentFile = 0;
             $this->strSelectedValueArray = array();
             // New locations
             $this->dtgLocation = new QDataGrid($this);
             $this->dtgLocation->Name = 'location_list';
             $this->dtgLocation->CellPadding = 5;
             $this->dtgLocation->CellSpacing = 0;
             $this->dtgLocation->CssClass = "datagrid";
             $this->dtgLocation->UseAjax = true;
             $this->dtgLocation->ShowColumnToggle = false;
             $this->dtgLocation->ShowExportCsv = false;
             $this->dtgLocation->ShowHeader = false;
             $this->dtgLocation->AddColumn(new QDataGridColumnExt('Location', '<?= $_ITEM ?>', 'CssClass="dtg_column"', 'HtmlEntities="false"'));
             // New categories
             $this->dtgCategory = new QDataGrid($this);
             $this->dtgCategory->Name = 'category_list';
             $this->dtgCategory->CellPadding = 5;
开发者ID:proxymoron,项目名称:tracmor,代码行数:67,代码来源:asset_import.php

示例3: Save

 public function Save($blnForceInsert = false, $blnForceUpdate = false)
 {
     //parent::Save($blnForceInsert, $blnForceUpdate);
     $objCustomFieldValue = $this->CustomFieldValue;
     if (!$objCustomFieldValue) {
         $objCustomFieldValue = $this->newCustomFieldValue;
     }
     if ($intCustomFieldId = $objCustomFieldValue->CustomFieldId) {
         // If helper table exists
         if ($strHelperTableArray = CustomFieldValue::GetHelperTableByEntityQtypeId($this->EntityQtypeId)) {
             $strHelperTable = $strHelperTableArray[0];
             $strTableName = $strHelperTableArray[1];
             $objDatabase = CustomField::GetDatabase();
             $strShortDescription = $objDatabase->SqlVariable($objCustomFieldValue->ShortDescription);
             $intEntityId = $objDatabase->SqlVariable($this->EntityId);
             $strQuery = sprintf("UPDATE %s SET `cfv_%s`=%s where `%s_id`=%s;", $strHelperTable, $intCustomFieldId, $strShortDescription, $strTableName, $intEntityId);
             $objDatabase->NonQuery($strQuery);
         }
     }
 }
开发者ID:proxymoron,项目名称:tracmor,代码行数:20,代码来源:CustomFieldSelection.class.php

示例4: DeleteAllEntityQtypeCustomFields

    /**
     * Deletes all associated EntityQtypeCustomFields
     * @return void
     */
    public function DeleteAllEntityQtypeCustomFields()
    {
        if (is_null($this->intCustomFieldId)) {
            throw new QUndefinedPrimaryKeyException('Unable to call UnassociateEntityQtypeCustomField on this unsaved CustomField.');
        }
        // Get the Database Object for this Class
        $objDatabase = CustomField::GetDatabase();
        // Perform the SQL Query
        $objDatabase->NonQuery('
				DELETE FROM
					`entity_qtype_custom_field`
				WHERE
					`custom_field_id` = ' . $objDatabase->SqlVariable($this->intCustomFieldId) . '
			');
    }
开发者ID:heshuai64,项目名称:einv2,代码行数:19,代码来源:CustomFieldGen.class.php

示例5: DeleteEntityQtypeCustomFields

 protected function DeleteEntityQtypeCustomFields()
 {
     $objEntityQtypeCustomFieldArray = EntityQtypeCustomField::LoadArrayByCustomFieldId($this->objCustomField->CustomFieldId);
     if ($objEntityQtypeCustomFieldArray) {
         foreach ($objEntityQtypeCustomFieldArray as $objEntityQtypeCustomField) {
             // If the EntityQtype needs to be deleted, you must delete EntityQtypeId for all roles in RoleEntityQTypeCustomFieldAuthorization
             $objRoleEntityCustomAuthArray = RoleEntityQtypeCustomFieldAuthorization::LoadArrayByEntityQtypeCustomFieldId($objEntityQtypeCustomField->EntityQtypeCustomFieldId);
             if ($objRoleEntityCustomAuthArray) {
                 foreach ($objRoleEntityCustomAuthArray as $objRoleEntityCustomAuth) {
                     $objRoleEntityCustomAuth->Delete();
                 }
             }
             // If there was Asset Type Custom field Delete AssetCustomField
             if ($objEntityQtypeCustomField->EntityQtypeId == 1) {
                 $this->DeleteAssetCustomFieldAssetModels();
             }
             // If the helper table exists for that EntityQtype delete the columns in the helper table
             if ($strHelperTableArray = CustomFieldValue::GetHelperTableByEntityQtypeId($objEntityQtypeCustomField->EntityQtypeId)) {
                 $strHelperTable = $strHelperTableArray[0];
                 $objDatabase = CustomField::GetDatabase();
                 $strQuery = sprintf("ALTER TABLE %s DROP `cfv_%s`;", $strHelperTable, $objEntityQtypeCustomField->CustomFieldId);
                 $objDatabase->NonQuery($strQuery);
             }
             // Delete the EntityQtypeCustomField last
             $objEntityQtypeCustomField->Delete();
         }
     }
 }
开发者ID:proxymoron,项目名称:tracmor,代码行数:28,代码来源:custom_field_edit.php

示例6: btnNext_Click


//.........这里部分代码省略.........
                                 }
                             }
                         } else {
                             $intDepreciationId = null;
                         }
                         //
                         $objAssetModel = false;
                         if (!$strShortDescription || $intCategoryId === false || $intManufacturerId === false || $intDepreciationId === false) {
                             //$blnError = true;
                             //echo sprintf("Desc: %s AssetCode: %s Cat: %s Man: %s<br/>", $strShortDescription, $strAssetModelCode, $intCategoryId, $intManufacturerId);
                             //break;
                             $strAssetModel = null;
                             $this->intSkippedRecordCount++;
                             $this->PutSkippedRecordInFile($file_skipped, $strRowArray);
                             continue;
                         } else {
                             //$blnError = false;
                             $strAssetModel = strtolower(sprintf("%s_%s_%s_%s", $strAssetModelCode, $strShortDescription, $intCategoryId, $intManufacturerId));
                             if ($this->lstImportAction->SelectedValue == 2) {
                                 $intItemId = intval(trim($strRowArray[$this->intItemIdKey]));
                                 if ($intItemId > 0 && array_key_exists($intItemId, $arrAssetModelId)) {
                                     $objAssetModelArray = AssetModel::LoadArrayBySearchHelper(null, null, null, null, null, null, null, null, null, null, null, null, $intItemId);
                                     if ($objAssetModelArray) {
                                         $objAssetModel = $objAssetModelArray[0];
                                     }
                                 }
                             } else {
                                 $intItemId = 0;
                             }
                         }
                         if ($strAssetModel && !$intItemId && !$this->in_array_nocase($strAssetModel, $strAssetModelArray)) {
                             // Custom Fields Section
                             $strCFVArray = array();
                             $objDatabase = CustomField::GetDatabase();
                             $blnCheckCFVError = false;
                             // Asset Model Custom Field import
                             foreach ($arrModelCustomField as $objCustomField) {
                                 if ($objCustomField->CustomFieldQtypeId != 2) {
                                     $strCSDescription = trim($strRowArray[$intModelCustomFieldKeyArray[$objCustomField->CustomFieldId]]);
                                     $strCSDescription = strlen($strCSDescription) > 0 ? addslashes($strCSDescription) : addslashes($this->txtMapDefaultValueArray[$intModelCustomFieldKeyArray[$objCustomField->CustomFieldId]]->Text);
                                     $strCFVArray[$objCustomField->CustomFieldId] = strlen($strCSDescription) > 0 ? sprintf("'%s'", $strCSDescription) : "NULL";
                                 } else {
                                     $objDatabase = AssetModel::GetDatabase();
                                     $strCSDescription = addslashes(trim($strRowArray[$intModelCustomFieldKeyArray[$objCustomField->CustomFieldId]]));
                                     $blnInList = false;
                                     foreach (CustomFieldValue::LoadArrayByCustomFieldId($objCustomField->CustomFieldId) as $objCustomFieldValue) {
                                         if (strtolower($objCustomFieldValue->ShortDescription) == strtolower($strCSDescription)) {
                                             //$intCustomFieldValueId = $objCustomFieldValue->CustomFieldValueId;
                                             $blnInList = true;
                                             break;
                                         }
                                     }
                                     // Add the CustomFieldValue
                                     // Removed adding new 'select' values
                                     /*if (!$blnInList && !in_array($strCSDescription, $strAddedCFVArray)) {
                                     			$strQuery = sprintf("INSERT INTO custom_field_value (custom_field_id, short_description, created_by, creation_date) VALUES (%s, '%s', %s, NOW());", $objCustomField->CustomFieldId, $strCSDescription, $_SESSION['intUserAccountId']);
                                     			$objDatabase->NonQuery($strQuery);
                                     			$strAddedCFVArray[] = $strCSDescription;
                                     		}
                                     		else*/
                                     if (!$blnInList && $this->lstMapDefaultValueArray[$intModelCustomFieldKeyArray[$objCustomField->CustomFieldId]]->SelectedValue != null) {
                                         $strCSDescription = $this->lstMapDefaultValueArray[$intModelCustomFieldKeyArray[$objCustomField->CustomFieldId]]->SelectedName;
                                     } elseif (!$blnInList) {
                                         $blnCheckCFVError = true;
                                         break;
                                     }
开发者ID:proxymoron,项目名称:tracmor,代码行数:67,代码来源:asset_model_import.php

示例7: UpdateAssetModelCustomFields

 protected function UpdateAssetModelCustomFields()
 {
     //$arrAssetCustomFieldsToAdd = array();
     // $this->chkAssetCustomFields->SelectedValues;
     // Generate array of Custom Field values for All Asset Models must be presented in all cases
     /*
     $arrAllAssetModelsFlaggedObjects = EntityQtypeCustomField::LoadArrayByEntityQtypeId(QApplication::Translate(EntityQtype::Asset));
     $arrAllAssetModelsFlag = array();
     foreach ($arrAllAssetModelsFlaggedObjects as $arrAllAssetModelsFlaggedObject){
       if ($arrAllAssetModelsFlaggedObject->CustomField->AllAssetModelsFlag){
         $arrAllAssetModelsFlag[] = $arrAllAssetModelsFlaggedObject->CustomField->CustomFieldId;
       }
     }
     
      $arrAssetCustomFieldsToAdd = array_merge($this->chkAssetCustomFields->SelectedValues,$arrAllAssetModelsFlag);
     */
     $arrAssetCustomFieldsToAdd = array_unique($this->chkAssetCustomFields->SelectedValues);
     // If new asset model add AssetCustomFields for All together with selected
     if (!$this->blnEditMode) {
         foreach ($arrAssetCustomFieldsToAdd as $keyAssetCustomField) {
             $newAssetCustomField = new AssetCustomFieldAssetModel();
             $newAssetCustomField->CustomFieldId = $keyAssetCustomField;
             $newAssetCustomField->AssetModelId = $this->objAssetModel->AssetModelId;
             $newAssetCustomField->Save();
         }
     } else {
         $currentAssetCustomFields = AssetCustomFieldAssetModel::LoadArrayByAssetModelId($this->objAssetModel->AssetModelId);
         foreach ($currentAssetCustomFields as $currentAssetCustomField) {
             if (!$currentAssetCustomField->CustomField->AllAssetModelsFlag && !in_array($currentAssetCustomField->CustomField->CustomFieldId, $arrAssetCustomFieldsToAdd)) {
                 // If blnEditMode some Assets for this Model can be already assigned and them values
                 // for this custom field must be set to null
                 $arrAssetsAssignedToModel = new Asset();
                 $arrAssetsAssignedToModel = $arrAssetsAssignedToModel->LoadArrayByAssetModelId($this->objAssetModel->AssetModelId);
                 if (count($arrAssetsAssignedToModel) > 0) {
                     $arrAssetOfModel = array();
                     foreach ($arrAssetsAssignedToModel as $objAssetAssignedToModel) {
                         array_push($arrAssetOfModel, $objAssetAssignedToModel->AssetId);
                     }
                     $arrAssetOfModel = implode(",", $arrAssetOfModel);
                     //print $arrAssetOfModel; exit;
                     $objDatabase = CustomField::GetDatabase();
                     $strQuery = sprintf("UPDATE `asset_custom_field_helper` SET `cfv_%s`= NULL WHERE `asset_id` IN({$arrAssetOfModel});", $currentAssetCustomField->CustomFieldId);
                     $objDatabase->NonQuery($strQuery);
                 }
                 // then Delete Associations
                 $currentAssetCustomField->Delete();
             }
         }
         foreach ($arrAssetCustomFieldsToAdd as $keyAssetCustomField) {
             $blnToAdd = true;
             foreach ($currentAssetCustomFields as $currentAssetCustomField) {
                 if ($currentAssetCustomField->CustomField->CustomFieldId == $arrAssetCustomFieldsToAdd) {
                     $blnToAdd = false;
                 }
             }
             if ($blnToAdd) {
                 $newAssetCustomField = new AssetCustomFieldAssetModel();
                 $newAssetCustomField->CustomFieldId = $keyAssetCustomField;
                 $newAssetCustomField->AssetModelId = $this->objAssetModel->AssetModelId;
                 $newAssetCustomField->Save();
                 // If custom field is required add default value to appropriate Assets
                 $objCustomFieldToAdd = new CustomField();
                 $objCustomFieldToAdd = $objCustomFieldToAdd->Load($keyAssetCustomField);
                 if ($objCustomFieldToAdd->RequiredFlag) {
                     $arrAssetsAssignedToModel = new Asset();
                     $arrAssetsAssignedToModel = $arrAssetsAssignedToModel->LoadArrayByAssetModelId($this->objAssetModel->AssetModelId);
                     if (count($arrAssetsAssignedToModel) > 0) {
                         $txtDefaultValue = CustomFieldValue::LoadByCustomFieldValueId($objCustomFieldToAdd->DefaultCustomFieldValueId);
                         $arrAssetOfModel = array();
                         foreach ($arrAssetsAssignedToModel as $objAssetAssignedToModel) {
                             array_push($arrAssetOfModel, $objAssetAssignedToModel->AssetId);
                         }
                         $arrAssetOfModel = implode(",", $arrAssetOfModel);
                         $objDatabase = CustomField::GetDatabase();
                         $strQuery = sprintf("UPDATE `asset_custom_field_helper` SET `cfv_%s`= %s WHERE `asset_id` IN({$arrAssetOfModel});", $keyAssetCustomField, $txtDefaultValue);
                         $objDatabase->NonQuery($strQuery);
                     }
                 }
                 //
             }
         }
     }
 }
开发者ID:proxymoron,项目名称:tracmor,代码行数:83,代码来源:asset_model_edit.php


注:本文中的CustomField::GetDatabase方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。