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


PHP QueryGenerator::addConditionGlue方法代码示例

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


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

示例1: createRecords

 public function createRecords()
 {
     $adb = PearDatabase::getInstance();
     $moduleName = $this->module;
     $focus = CRMEntity::getInstance($moduleName);
     $moduleHandler = vtws_getModuleHandlerFromName($moduleName, $this->user);
     $moduleMeta = $moduleHandler->getMeta();
     $moduleObjectId = $moduleMeta->getEntityId();
     $moduleFields = $moduleMeta->getModuleFields();
     $tableName = Import_Utils::getDbTableName($this->user);
     $sql = 'SELECT * FROM ' . $tableName . ' WHERE status = ' . Import_Data_Controller::$IMPORT_RECORD_NONE;
     if ($this->batchImport) {
         $configReader = new ConfigReader('modules/Import/config.inc', 'ImportConfig');
         $importBatchLimit = $configReader->getConfig('importBatchLimit');
         $sql .= ' LIMIT ' . $importBatchLimit;
     }
     $result = $adb->query($sql);
     $numberOfRecords = $adb->num_rows($result);
     if ($numberOfRecords <= 0) {
         return;
     }
     $fieldMapping = $this->fieldMapping;
     $fieldColumnMapping = $moduleMeta->getFieldColumnMapping();
     for ($i = 0; $i < $numberOfRecords; ++$i) {
         $row = $adb->raw_query_result_rowdata($result, $i);
         $rowId = $row['id'];
         $entityInfo = null;
         $fieldData = array();
         foreach ($fieldMapping as $fieldName => $index) {
             $fieldData[$fieldName] = $row[$fieldName];
         }
         $mergeType = $this->mergeType;
         $createRecord = false;
         if (method_exists($focus, 'importRecord')) {
             $entityInfo = $focus->importRecord($this, $fieldData);
         } else {
             if (!empty($mergeType) && $mergeType != Import_Utils::$AUTO_MERGE_NONE) {
                 $queryGenerator = new QueryGenerator($moduleName, $this->user);
                 $queryGenerator->initForDefaultCustomView();
                 $fieldsList = array('id');
                 $queryGenerator->setFields($fieldsList);
                 $mergeFields = $this->mergeFields;
                 foreach ($mergeFields as $index => $mergeField) {
                     if ($index != 0) {
                         $queryGenerator->addConditionGlue(QueryGenerator::$AND);
                     }
                     $comparisonValue = $fieldData[$mergeField];
                     $fieldInstance = $moduleFields[$mergeField];
                     if ($fieldInstance->getFieldDataType() == 'owner') {
                         $userId = getUserId_Ol($comparisonValue);
                         $comparisonValue = getUserFullName($userId);
                     }
                     if ($fieldInstance->getFieldDataType() == 'reference') {
                         if (strpos($comparisonValue, '::::') > 0) {
                             $referenceFileValueComponents = explode('::::', $comparisonValue);
                         } else {
                             $referenceFileValueComponents = explode(':::', $comparisonValue);
                         }
                         if (count($referenceFileValueComponents) > 1) {
                             $comparisonValue = trim($referenceFileValueComponents[1]);
                         }
                     }
                     $queryGenerator->addCondition($mergeField, $comparisonValue, 'e');
                 }
                 $query = $queryGenerator->getQuery();
                 $duplicatesResult = $adb->query($query);
                 $noOfDuplicates = $adb->num_rows($duplicatesResult);
                 if ($noOfDuplicates > 0) {
                     if ($mergeType == Import_Utils::$AUTO_MERGE_IGNORE) {
                         $entityInfo['status'] = self::$IMPORT_RECORD_SKIPPED;
                     } elseif ($mergeType == Import_Utils::$AUTO_MERGE_OVERWRITE || $mergeType == Import_Utils::$AUTO_MERGE_MERGEFIELDS) {
                         for ($index = 0; $index < $noOfDuplicates - 1; ++$index) {
                             $duplicateRecordId = $adb->query_result($duplicatesResult, $index, $fieldColumnMapping['id']);
                             $entityId = vtws_getId($moduleObjectId, $duplicateRecordId);
                             vtws_delete($entityId, $this->user);
                         }
                         $baseRecordId = $adb->query_result($duplicatesResult, $noOfDuplicates - 1, $fieldColumnMapping['id']);
                         $baseEntityId = vtws_getId($moduleObjectId, $baseRecordId);
                         if ($mergeType == Import_Utils::$AUTO_MERGE_OVERWRITE) {
                             $fieldData = $this->transformForImport($fieldData, $moduleMeta);
                             $fieldData['id'] = $baseEntityId;
                             $entityInfo = vtws_update($fieldData, $this->user);
                             $entityInfo['status'] = self::$IMPORT_RECORD_UPDATED;
                             //Prepare data for event handler
                             $entityData = array();
                             $entityData['rowId'] = $rowId;
                             $entityData['tableName'] = $tableName;
                             $entityData['entityInfo'] = $entityInfo;
                             $entityData['fieldData'] = $fieldData;
                             $entityData['moduleName'] = $moduleName;
                             $entityData['user'] = $this->user;
                             cbEventHandler::do_action('corebos.entity.import.overwrite', $entityData);
                         }
                         if ($mergeType == Import_Utils::$AUTO_MERGE_MERGEFIELDS) {
                             $filteredFieldData = array();
                             $defaultFieldValues = $this->getDefaultFieldValues($moduleMeta);
                             foreach ($fieldData as $fieldName => $fieldValue) {
                                 if (!empty($fieldValue)) {
                                     $filteredFieldData[$fieldName] = $fieldValue;
                                 }
//.........这里部分代码省略.........
开发者ID:casati-dolibarr,项目名称:corebos,代码行数:101,代码来源:Import_Data_Controller.php

示例2: showSearchResults

 /**
  * Function to display the Search Results
  * @param Vtiger_Request $request
  */
 function showSearchResults(Vtiger_Request $request)
 {
     $db = PearDatabase::getInstance();
     $viewer = $this->getViewer($request);
     $moduleName = $request->getModule();
     $advFilterList = $request->get('advfilterlist');
     //used to show the save modify filter option
     $isAdvanceSearch = false;
     $matchingRecords = array();
     if (is_array($advFilterList) && count($advFilterList) > 0) {
         $isAdvanceSearch = true;
         $user = Users_Record_Model::getCurrentUserModel();
         $queryGenerator = new QueryGenerator($moduleName, $user);
         $queryGenerator->setFields(array('id'));
         vimport('~~/modules/CustomView/CustomView.php');
         $customView = new CustomView($moduleName);
         $dateSpecificConditions = $customView->getStdFilterConditions();
         foreach ($advFilterList as $groupindex => $groupcolumns) {
             $filtercolumns = $groupcolumns['columns'];
             if (count($filtercolumns) > 0) {
                 $queryGenerator->startGroup('');
                 foreach ($filtercolumns as $index => $filter) {
                     $nameComponents = explode(':', $filter['columnname']);
                     if (empty($nameComponents[2]) && $nameComponents[1] == 'crmid' && $nameComponents[0] == 'vtiger_crmentity') {
                         $name = $queryGenerator->getSQLColumn('id');
                     } else {
                         $name = $nameComponents[2];
                     }
                     if (($nameComponents[4] == 'D' || $nameComponents[4] == 'DT') && in_array($filter['comparator'], $dateSpecificConditions)) {
                         $filter['stdfilter'] = $filter['comparator'];
                         $valueComponents = explode(',', $filter['value']);
                         if ($filter['comparator'] == 'custom') {
                             $filter['startdate'] = DateTimeField::convertToDBFormat($valueComponents[0]);
                             $filter['enddate'] = DateTimeField::convertToDBFormat($valueComponents[1]);
                         }
                         $dateFilterResolvedList = $customView->resolveDateFilterValue($filter);
                         $value[] = $queryGenerator->fixDateTimeValue($name, $dateFilterResolvedList['startdate']);
                         $value[] = $queryGenerator->fixDateTimeValue($name, $dateFilterResolvedList['enddate'], false);
                         $queryGenerator->addCondition($name, $value, 'BETWEEN');
                     } else {
                         $queryGenerator->addCondition($name, $filter['value'], $filter['comparator']);
                     }
                     $columncondition = $filter['column_condition'];
                     if (!empty($columncondition) && array_key_exists($index + 1, $filtercolumns)) {
                         $queryGenerator->addConditionGlue($columncondition);
                     }
                 }
                 $queryGenerator->endGroup();
                 $groupConditionGlue = $groupcolumns['condition'];
                 if (!empty($groupConditionGlue)) {
                     $queryGenerator->addConditionGlue($groupConditionGlue);
                 }
             }
         }
         $query = $queryGenerator->getQuery();
         //Remove the ordering for now to improve the speed
         //$query .= ' ORDER BY createdtime DESC';
         $result = $db->pquery($query, array());
         $rows = $db->num_rows($result);
         for ($i = 0; $i < $rows; ++$i) {
             $row = $db->query_result_rowdata($result, $i);
             $recordInstance = Vtiger_Record_Model::getInstanceById($row[0]);
             $moduleName = $recordInstance->getModuleName();
             $matchingRecords[$moduleName][$row[0]] = $recordInstance;
         }
         $viewer->assign('SEARCH_MODULE', $moduleName);
     } else {
         $searchKey = $request->get('value');
         $searchModule = false;
         if ($request->get('searchModule')) {
             $searchModule = $request->get('searchModule');
         }
         $viewer->assign('SEARCH_KEY', $searchKey);
         $viewer->assign('SEARCH_MODULE', $searchModule);
         $matchingRecords = Vtiger_Record_Model::getSearchResult($searchKey, $searchModule);
     }
     $matchingRecordsList = array();
     if ($matchingRecords[$moduleName]) {
         $matchingRecordsList[$moduleName] = $matchingRecords[$moduleName];
     }
     foreach ($matchingRecords as $module => $recordModelsList) {
         $matchingRecordsList[$module] = $recordModelsList;
     }
     $viewer->assign('MODULE', $moduleName);
     $viewer->assign('MATCHING_RECORDS', $matchingRecordsList);
     $viewer->assign('IS_ADVANCE_SEARCH', $isAdvanceSearch);
     echo $viewer->view('UnifiedSearchResults.tpl', '', true);
 }
开发者ID:JeRRimix,项目名称:YetiForceCRM,代码行数:92,代码来源:BasicAjax.php

示例3: createRecords

 public function createRecords()
 {
     $adb = PearDatabase::getInstance();
     $moduleName = $this->module;
     $focus = CRMEntity::getInstance($moduleName);
     $moduleHandler = vtws_getModuleHandlerFromName($moduleName, $this->user);
     $moduleMeta = $moduleHandler->getMeta();
     $moduleObjectId = $moduleMeta->getEntityId();
     $moduleFields = $moduleMeta->getModuleFields();
     $entityData = array();
     $tableName = Import_Utils_Helper::getDbTableName($this->user);
     $sql = 'SELECT * FROM ' . $tableName . ' WHERE status = ' . Import_Data_Action::$IMPORT_RECORD_NONE;
     if ($this->batchImport) {
         $configReader = new Import_Config_Model();
         $importBatchLimit = $configReader->get('importBatchLimit');
         $sql .= ' LIMIT ' . $importBatchLimit;
     }
     $result = $adb->query($sql);
     $numberOfRecords = $adb->num_rows($result);
     if ($numberOfRecords <= 0) {
         return;
     }
     $fieldMapping = $this->fieldMapping;
     $fieldColumnMapping = $moduleMeta->getFieldColumnMapping();
     for ($i = 0; $i < $numberOfRecords; ++$i) {
         $row = $adb->raw_query_result_rowdata($result, $i);
         $rowId = $row['id'];
         $entityInfo = null;
         $fieldData = array();
         foreach ($fieldMapping as $fieldName => $index) {
             $fieldData[$fieldName] = $row[$fieldName];
         }
         $mergeType = $this->mergeType;
         $createRecord = false;
         if (method_exists($focus, 'importRecord')) {
             $entityInfo = $focus->importRecord($this, $fieldData);
         } else {
             if (!empty($mergeType) && $mergeType != Import_Utils_Helper::$AUTO_MERGE_NONE) {
                 $queryGenerator = new QueryGenerator($moduleName, $this->user);
                 $customView = new CustomView($moduleName);
                 $viewId = $customView->getViewIdByName('All', $moduleName);
                 if (!empty($viewId)) {
                     $queryGenerator->initForCustomViewById($viewId);
                 } else {
                     $queryGenerator->initForDefaultCustomView();
                 }
                 $fieldsList = array('id');
                 $queryGenerator->setFields($fieldsList);
                 $mergeFields = $this->mergeFields;
                 if ($queryGenerator->getWhereFields() && $mergeFields) {
                     $queryGenerator->addConditionGlue(QueryGenerator::$AND);
                 }
                 foreach ($mergeFields as $index => $mergeField) {
                     if ($index != 0) {
                         $queryGenerator->addConditionGlue(QueryGenerator::$AND);
                     }
                     $comparisonValue = $fieldData[$mergeField];
                     $fieldInstance = $moduleFields[$mergeField];
                     if ($fieldInstance->getFieldDataType() == 'owner') {
                         $userId = getUserId_Ol($comparisonValue);
                         $comparisonValue = getUserFullName($userId);
                     }
                     if ($fieldInstance->getFieldDataType() == 'reference') {
                         if (strpos($comparisonValue, '::::') > 0) {
                             $referenceFileValueComponents = explode('::::', $comparisonValue);
                         } else {
                             $referenceFileValueComponents = explode(':::', $comparisonValue);
                         }
                         if (count($referenceFileValueComponents) > 1) {
                             $comparisonValue = trim($referenceFileValueComponents[1]);
                         }
                     }
                     $queryGenerator->addCondition($mergeField, $comparisonValue, 'e', '', '', '', true);
                 }
                 $query = $queryGenerator->getQuery();
                 $duplicatesResult = $adb->query($query);
                 $noOfDuplicates = $adb->num_rows($duplicatesResult);
                 if ($noOfDuplicates > 0) {
                     if ($mergeType == Import_Utils_Helper::$AUTO_MERGE_IGNORE) {
                         $entityInfo['status'] = self::$IMPORT_RECORD_SKIPPED;
                     } elseif ($mergeType == Import_Utils_Helper::$AUTO_MERGE_OVERWRITE || $mergeType == Import_Utils_Helper::$AUTO_MERGE_MERGEFIELDS) {
                         for ($index = 0; $index < $noOfDuplicates - 1; ++$index) {
                             $duplicateRecordId = $adb->query_result($duplicatesResult, $index, $fieldColumnMapping['id']);
                             $entityId = vtws_getId($moduleObjectId, $duplicateRecordId);
                             vtws_delete($entityId, $this->user);
                         }
                         $baseRecordId = $adb->query_result($duplicatesResult, $noOfDuplicates - 1, $fieldColumnMapping['id']);
                         $baseEntityId = vtws_getId($moduleObjectId, $baseRecordId);
                         if ($mergeType == Import_Utils_Helper::$AUTO_MERGE_OVERWRITE) {
                             $fieldData = $this->transformForImport($fieldData, $moduleMeta);
                             $fieldData['id'] = $baseEntityId;
                             $entityInfo = vtws_update($fieldData, $this->user);
                             $entityInfo['status'] = self::$IMPORT_RECORD_UPDATED;
                         }
                         if ($mergeType == Import_Utils_Helper::$AUTO_MERGE_MERGEFIELDS) {
                             $filteredFieldData = array();
                             foreach ($fieldData as $fieldName => $fieldValue) {
                                 // empty will give false for value = 0
                                 if (!empty($fieldValue) || $fieldValue != "") {
                                     $filteredFieldData[$fieldName] = $fieldValue;
//.........这里部分代码省略.........
开发者ID:cannking,项目名称:vtigercrm-debug,代码行数:101,代码来源:Data.php

示例4: showSearchResults

 /**
  * Function to display the Search Results
  * @param Vtiger_Request $request
  */
 function showSearchResults(Vtiger_Request $request)
 {
     $db = PearDatabase::getInstance();
     $viewer = $this->getViewer($request);
     $moduleName = $request->getModule();
     $advFilterList = $request->get('advfilterlist');
     //used to show the save modify filter option
     $isAdvanceSearch = false;
     $matchingRecords = array();
     if (is_array($advFilterList) && count($advFilterList) > 0) {
         $isAdvanceSearch = true;
         $user = Users_Record_Model::getCurrentUserModel();
         $queryGenerator = new QueryGenerator($moduleName, $user);
         $queryGenerator->setFields(['id']);
         vimport('~modules/CustomView/CustomView.php');
         $customView = new CustomView($moduleName);
         $dateSpecificConditions = $customView->getStdFilterConditions();
         foreach ($advFilterList as $groupindex => $groupcolumns) {
             $filtercolumns = $groupcolumns['columns'];
             if (count($filtercolumns) > 0) {
                 $queryGenerator->startGroup('');
                 foreach ($filtercolumns as $index => $filter) {
                     $nameComponents = explode(':', $filter['columnname']);
                     if (empty($nameComponents[2]) && $nameComponents[1] == 'crmid' && $nameComponents[0] == 'vtiger_crmentity') {
                         $name = $queryGenerator->getSQLColumn('id');
                     } else {
                         $name = $nameComponents[2];
                     }
                     if (($nameComponents[4] == 'D' || $nameComponents[4] == 'DT') && in_array($filter['comparator'], $dateSpecificConditions)) {
                         $filter['stdfilter'] = $filter['comparator'];
                         $valueComponents = explode(',', $filter['value']);
                         if ($filter['comparator'] == 'custom') {
                             $filter['startdate'] = DateTimeField::convertToDBFormat($valueComponents[0]);
                             $filter['enddate'] = DateTimeField::convertToDBFormat($valueComponents[1]);
                         }
                         $dateFilterResolvedList = $customView->resolveDateFilterValue($filter);
                         $value[] = $queryGenerator->fixDateTimeValue($name, $dateFilterResolvedList['startdate']);
                         $value[] = $queryGenerator->fixDateTimeValue($name, $dateFilterResolvedList['enddate'], false);
                         $queryGenerator->addCondition($name, $value, 'BETWEEN');
                     } else {
                         $queryGenerator->addCondition($name, $filter['value'], $filter['comparator']);
                     }
                     $columncondition = $filter['column_condition'];
                     if (!empty($columncondition) && array_key_exists($index + 1, $filtercolumns)) {
                         $queryGenerator->addConditionGlue($columncondition);
                     }
                 }
                 $queryGenerator->endGroup();
                 $groupConditionGlue = $groupcolumns['condition'];
                 if (!empty($groupConditionGlue)) {
                     $queryGenerator->addConditionGlue($groupConditionGlue);
                 }
             }
         }
         $query = $queryGenerator->getQuery();
         //Remove the ordering for now to improve the speed
         //$query .= ' ORDER BY createdtime DESC';
         $result = $db->query($query);
         while ($row = $db->fetch_array($result)) {
             $recordInstance = Vtiger_Record_Model::getInstanceById(current($row));
             $moduleName = $recordInstance->getModuleName();
             $recordInstance->set('permitted', true);
             $matchingRecords[$moduleName][current($row)] = $recordInstance;
         }
         $viewer->assign('SEARCH_MODULE', $moduleName);
     } else {
         $searchKey = $request->get('value');
         $searchModule = false;
         if ($request->get('searchModule')) {
             $searchModule = $request->get('searchModule');
         }
         $viewer->assign('SEARCH_KEY', $searchKey);
         $viewer->assign('SEARCH_MODULE', $searchModule);
         $matchingRecords = Vtiger_Record_Model::getSearchResult($searchKey, $searchModule, $request->get('limit'));
     }
     $recordsList = $matchingRecordsList = [];
     if ($matchingRecords[$moduleName]) {
         $matchingRecordsList[$moduleName] = $matchingRecords[$moduleName];
     }
     foreach ($matchingRecords as $module => $recordModelsList) {
         $matchingRecordsList[$module] = $recordModelsList;
     }
     if ($request->get('html') == 'true') {
         $viewer->assign('MODULE', $moduleName);
         $viewer->assign('MATCHING_RECORDS', $matchingRecordsList);
         $viewer->assign('IS_ADVANCE_SEARCH', $isAdvanceSearch);
         echo $viewer->view('UnifiedSearchResults.tpl', '', true);
     } else {
         foreach ($matchingRecordsList as $module => $modules) {
             foreach ($modules as $recordID => $recordModel) {
                 $label = decode_html($recordModel->getName());
                 $label .= ' (' . Vtiger_Functions::getOwnerRecordLabel($recordModel->get('smownerid')) . ')';
                 if (!$recordModel->get('permitted')) {
                     $label .= ' <span class="glyphicon glyphicon-warning-sign" aria-hidden="true"></span>';
                 }
                 $recordsList[] = ['id' => $recordID, 'module' => $module, 'category' => vtranslate($module, $module), 'label' => $label, 'permitted' => $recordModel->get('permitted')];
//.........这里部分代码省略.........
开发者ID:rcrrich,项目名称:YetiForceCRM,代码行数:101,代码来源:BasicAjax.php


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