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


PHP DBObjectSearch::SetDataFiltered方法代码示例

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


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

示例1: MakeSelectStructure

 protected static function MakeSelectStructure(DBObjectSearch $oFilter, $aOrderBy, $aArgs, $aAttToLoad, $aExtendedDataSpec, $iLimitCount, $iLimitStart, $bGetCount, $aGroupByExpr = null)
 {
     // Hide objects that are not visible to the current user
     //
     if (!$oFilter->IsAllDataAllowed() && !$oFilter->IsDataFiltered()) {
         $oVisibleObjects = UserRights::GetSelectFilter($oFilter->GetClass(), $oFilter->GetModifierProperties('UserRightsGetSelectFilter'));
         if ($oVisibleObjects === false) {
             // Make sure this is a valid search object, saying NO for all
             $oVisibleObjects = DBObjectSearch::FromEmptySet($oFilter->GetClass());
         }
         if (is_object($oVisibleObjects)) {
             $oFilter->MergeWith($oVisibleObjects);
             $oFilter->SetDataFiltered();
         } else {
             // should be true at this point, meaning that no additional filtering
             // is required
         }
     }
     // Compute query modifiers properties (can be set in the search itself, by the context, etc.)
     //
     $aModifierProperties = self::MakeModifierProperties($oFilter);
     // Create a unique cache id
     //
     if (self::$m_bQueryCacheEnabled || self::$m_bTraceQueries) {
         // Need to identify the query
         $sOqlQuery = $oFilter->ToOql();
         if (count($aModifierProperties)) {
             array_multisort($aModifierProperties);
             $sModifierProperties = json_encode($aModifierProperties);
         } else {
             $sModifierProperties = '';
         }
         $sRawId = $sOqlQuery . $sModifierProperties;
         if (!is_null($aAttToLoad)) {
             $sRawId .= json_encode($aAttToLoad);
         }
         if (!is_null($aGroupByExpr)) {
             foreach ($aGroupByExpr as $sAlias => $oExpr) {
                 $sRawId .= 'g:' . $sAlias . '!' . $oExpr->Render();
             }
         }
         $sRawId .= $bGetCount;
         $sOqlId = md5($sRawId);
     } else {
         $sOqlQuery = "SELECTING... " . $oFilter->GetClass();
         $sOqlId = "query id ? n/a";
     }
     // Query caching
     //
     if (self::$m_bQueryCacheEnabled) {
         // Warning: using directly the query string as the key to the hash array can FAIL if the string
         // is long and the differences are only near the end... so it's safer (but not bullet proof?)
         // to use a hash (like md5) of the string as the key !
         //
         // Example of two queries that were found as similar by the hash array:
         // SELECT SLT JOIN lnkSLTToSLA AS L1 ON L1.slt_id=SLT.id JOIN SLA ON L1.sla_id = SLA.id JOIN lnkContractToSLA AS L2 ON L2.sla_id = SLA.id JOIN CustomerContract ON L2.contract_id = CustomerContract.id WHERE SLT.ticket_priority = 1 AND SLA.service_id = 3 AND SLT.metric = 'TTO' AND CustomerContract.customer_id = 2
         // and
         // SELECT SLT JOIN lnkSLTToSLA AS L1 ON L1.slt_id=SLT.id JOIN SLA ON L1.sla_id = SLA.id JOIN lnkContractToSLA AS L2 ON L2.sla_id = SLA.id JOIN CustomerContract ON L2.contract_id = CustomerContract.id WHERE SLT.ticket_priority = 1 AND SLA.service_id = 3 AND SLT.metric = 'TTR' AND CustomerContract.customer_id = 2
         // the only difference is R instead or O at position 285 (TTR instead of TTO)...
         //
         if (array_key_exists($sOqlId, self::$m_aQueryStructCache)) {
             // hit!
             $oSelect = unserialize(serialize(self::$m_aQueryStructCache[$sOqlId]));
             // Note: cloning is not enough because the subtree is made of objects
         } elseif (self::$m_bUseAPCCache) {
             // Note: For versions of APC older than 3.0.17, fetch() accepts only one parameter
             //
             $sOqlAPCCacheId = 'itop-' . MetaModel::GetEnvironmentId() . '-query-cache-' . $sOqlId;
             $oKPI = new ExecutionKPI();
             $result = apc_fetch($sOqlAPCCacheId);
             $oKPI->ComputeStats('Query APC (fetch)', $sOqlQuery);
             if (is_object($result)) {
                 $oSelect = $result;
                 self::$m_aQueryStructCache[$sOqlId] = $oSelect;
             }
         }
     }
     if (!isset($oSelect)) {
         $oBuild = new QueryBuilderContext($oFilter, $aModifierProperties, $aGroupByExpr);
         $oKPI = new ExecutionKPI();
         $oSelect = self::MakeQuery($oBuild, $oFilter, $aAttToLoad, array(), true);
         $oSelect->SetCondition($oBuild->m_oQBExpressions->GetCondition());
         $oSelect->SetSourceOQL($sOqlQuery);
         if ($aGroupByExpr) {
             $aCols = $oBuild->m_oQBExpressions->GetGroupBy();
             $oSelect->SetGroupBy($aCols);
             $oSelect->SetSelect($aCols);
         } else {
             $oSelect->SetSelect($oBuild->m_oQBExpressions->GetSelect());
         }
         if (self::$m_bOptimizeQueries) {
             if ($bGetCount) {
                 // Simplify the query if just getting the count
                 $oSelect->SetSelect(array());
             }
             $oBuild->m_oQBExpressions->GetMandatoryTables($aMandatoryTables);
             $oSelect->OptimizeJoins($aMandatoryTables);
         }
         $oKPI->ComputeStats('MakeQuery (select)', $sOqlQuery);
         if (self::$m_bQueryCacheEnabled) {
//.........这里部分代码省略.........
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:101,代码来源:metamodel.class.php


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