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


PHP DBObjectSearch::AddCondition_PointingTo方法代码示例

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


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

示例1: FilterByContext

/**
 * Adds the context parameters to the audit query
 */
function FilterByContext(DBObjectSearch &$oFilter, ApplicationContext $oAppContext)
{
    $sObjClass = $oFilter->GetClass();
    $aContextParams = $oAppContext->GetNames();
    $aCallSpec = array($sObjClass, 'MapContextParam');
    if (is_callable($aCallSpec)) {
        foreach ($aContextParams as $sParamName) {
            $sValue = $oAppContext->GetCurrentValue($sParamName, null);
            if ($sValue != null) {
                $sAttCode = call_user_func($aCallSpec, $sParamName);
                // Returns null when there is no mapping for this parameter
                if ($sAttCode != null && MetaModel::IsValidAttCode($sObjClass, $sAttCode)) {
                    // Check if the condition points to a hierarchical key
                    if ($sAttCode == 'id') {
                        // Filtering on the objects themselves
                        $sHierarchicalKeyCode = MetaModel::IsHierarchicalClass($sObjClass);
                        if ($sHierarchicalKeyCode !== false) {
                            $oRootFilter = new DBObjectSearch($sObjClass);
                            $oRootFilter->AddCondition($sAttCode, $sValue);
                            $oFilter->AddCondition_PointingTo($oRootFilter, $sHierarchicalKeyCode, TREE_OPERATOR_BELOW);
                            // Use the 'below' operator by default
                            $bConditionAdded = true;
                        }
                    } else {
                        $oAttDef = MetaModel::GetAttributeDef($sObjClass, $sAttCode);
                        $bConditionAdded = false;
                        if ($oAttDef->IsExternalKey()) {
                            $sHierarchicalKeyCode = MetaModel::IsHierarchicalClass($oAttDef->GetTargetClass());
                            if ($sHierarchicalKeyCode !== false) {
                                $oRootFilter = new DBObjectSearch($oAttDef->GetTargetClass());
                                $oRootFilter->AddCondition('id', $sValue);
                                $oHKFilter = new DBObjectSearch($oAttDef->GetTargetClass());
                                $oHKFilter->AddCondition_PointingTo($oRootFilter, $sHierarchicalKeyCode, TREE_OPERATOR_BELOW);
                                // Use the 'below' operator by default
                                $oFilter->AddCondition_PointingTo($oHKFilter, $sAttCode);
                                $bConditionAdded = true;
                            }
                        }
                    }
                    if (!$bConditionAdded) {
                        $oFilter->AddCondition($sAttCode, $sValue);
                    }
                }
            }
        }
    }
}
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:50,代码来源:audit.php

示例2: AddCondition

 /**
  * Add a condition (restriction) to the current DBSearch on which the display block is based
  * taking into account the hierarchical keys for which the condition is based on the 'below' operator
  */
 protected function AddCondition($sFilterCode, $condition, $sOpCode = null)
 {
     // Workaround to an issue revealed whenever a condition on org_id is applied twice (with a hierarchy of organizations)
     // Moreover, it keeps the query as simple as possible
     if (isset($this->m_aConditions[$sFilterCode]) && $condition == $this->m_aConditions[$sFilterCode]) {
         // Skip
         return;
     }
     $this->m_aConditions[$sFilterCode] = $condition;
     $sClass = $this->m_oFilter->GetClass();
     $bConditionAdded = false;
     // If the condition is an external key with a class having a hierarchy, use a "below" criteria
     if (MetaModel::IsValidAttCode($sClass, $sFilterCode)) {
         $oAttDef = MetaModel::GetAttributeDef($sClass, $sFilterCode);
         if ($oAttDef->IsExternalKey()) {
             $sHierarchicalKeyCode = MetaModel::IsHierarchicalClass($oAttDef->GetTargetClass());
             if ($sHierarchicalKeyCode !== false) {
                 $oFilter = new DBObjectSearch($oAttDef->GetTargetClass());
                 if ($sOpCode == 'IN' && is_array($condition)) {
                     $oFilter->AddConditionExpression(self::GetConditionIN($oFilter, 'id', $condition));
                 } else {
                     $oFilter->AddCondition('id', $condition);
                 }
                 $oHKFilter = new DBObjectSearch($oAttDef->GetTargetClass());
                 $oHKFilter->AddCondition_PointingTo($oFilter, $sHierarchicalKeyCode, TREE_OPERATOR_BELOW);
                 // Use the 'below' operator by default
                 $this->m_oFilter->AddCondition_PointingTo($oHKFilter, $sFilterCode);
                 $bConditionAdded = true;
             } else {
                 if ($sOpCode == 'IN' && is_array($condition)) {
                     $this->m_oFilter->AddConditionExpression(self::GetConditionIN($this->m_oFilter, $sFilterCode, $condition));
                     $bConditionAdded = true;
                 }
             }
         } else {
             if ($sOpCode == 'IN' && is_array($condition)) {
                 $this->m_oFilter->AddConditionExpression(self::GetConditionIN($this->m_oFilter, $sFilterCode, $condition));
                 $bConditionAdded = true;
             }
         }
     }
     // In all other cases, just add the condition directly
     if (!$bConditionAdded) {
         $this->m_oFilter->AddCondition($sFilterCode, $condition);
         // Use the default 'loose' operator
     }
 }
开发者ID:henryavila,项目名称:itop,代码行数:51,代码来源:displayblock.class.inc.php

示例3: Reload

 public function Reload()
 {
     assert($this->m_bIsInDB);
     $aRow = MetaModel::MakeSingleRow(get_class($this), $this->m_iKey, false);
     if (empty($aRow)) {
         throw new CoreException("Failed to reload object of class '" . get_class($this) . "', id = " . $this->m_iKey);
     }
     $this->FromRow($aRow);
     // Process linked set attributes
     //
     foreach (MetaModel::ListAttributeDefs(get_class($this)) as $sAttCode => $oAttDef) {
         if (!$oAttDef->IsLinkSet()) {
             continue;
         }
         // Load the link information
         $sLinkClass = $oAttDef->GetLinkedClass();
         $sExtKeyToMe = $oAttDef->GetExtKeyToMe();
         // The class to target is not the current class, because if this is a derived class,
         // it may differ from the target class, then things start to become confusing
         $oRemoteExtKeyAtt = MetaModel::GetAttributeDef($sLinkClass, $sExtKeyToMe);
         $sMyClass = $oRemoteExtKeyAtt->GetTargetClass();
         $oMyselfSearch = new DBObjectSearch($sMyClass);
         $oMyselfSearch->AddCondition('id', $this->m_iKey, '=');
         $oLinkSearch = new DBObjectSearch($sLinkClass);
         $oLinkSearch->AddCondition_PointingTo($oMyselfSearch, $sExtKeyToMe);
         $oLinks = new DBObjectSet($oLinkSearch);
         $this->m_aCurrValues[$sAttCode] = $oLinks;
         $this->m_aOrigValues[$sAttCode] = clone $this->m_aCurrValues[$sAttCode];
         $this->m_aLoadedAtt[$sAttCode] = true;
     }
     $this->m_bFullyLoaded = true;
     $this->m_aModifiedAtt = array();
 }
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:33,代码来源:dbobject.class.php


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