本文整理汇总了PHP中DBObjectSearch::AddConditionAdvanced方法的典型用法代码示例。如果您正苦于以下问题:PHP DBObjectSearch::AddConditionAdvanced方法的具体用法?PHP DBObjectSearch::AddConditionAdvanced怎么用?PHP DBObjectSearch::AddConditionAdvanced使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBObjectSearch
的用法示例。
在下文中一共展示了DBObjectSearch::AddConditionAdvanced方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PostedParamsToFilter
public function PostedParamsToFilter($sClass, $aAttList, $sPrefix)
{
$oFilter = new DBObjectSearch($sClass);
$iCountParams = 0;
foreach ($aAttList as $sAttSpec) {
$sFieldName = str_replace('->', PARAM_ARROW_SEP, $sAttSpec);
$value = utils::ReadPostedParam($sPrefix . $sFieldName, null, 'raw_data');
if (!is_null($value) && (is_array($value) ? count($value) > 0 : strlen($value) > 0)) {
$oFilter->AddConditionAdvanced($sAttSpec, $value);
$iCountParams++;
}
}
if ($iCountParams == 0) {
return null;
} else {
return $oFilter;
}
}
示例2: AddConditionAdvanced
/**
* Specify a condition on external keys or link sets
* @param sAttSpec Can be either an attribute code or extkey->[sAttSpec] or linkset->[sAttSpec] and so on, recursively
* Example: infra_list->ci_id->location_id->country
* @param value The value to match (can be an array => IN(val1, val2...)
* @return void
*/
public function AddConditionAdvanced($sAttSpec, $value)
{
$sClass = $this->GetClass();
$iPos = strpos($sAttSpec, '->');
if ($iPos !== false) {
$sAttCode = substr($sAttSpec, 0, $iPos);
$sSubSpec = substr($sAttSpec, $iPos + 2);
if (!MetaModel::IsValidAttCode($sClass, $sAttCode)) {
throw new Exception("Invalid attribute code '{$sClass}/{$sAttCode}' in condition specification '{$sAttSpec}'");
}
$oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
if ($oAttDef->IsLinkSet()) {
$sTargetClass = $oAttDef->GetLinkedClass();
$sExtKeyToMe = $oAttDef->GetExtKeyToMe();
$oNewFilter = new DBObjectSearch($sTargetClass);
$oNewFilter->AddConditionAdvanced($sSubSpec, $value);
$this->AddCondition_ReferencedBy($oNewFilter, $sExtKeyToMe);
} elseif ($oAttDef->IsExternalKey(EXTKEY_ABSOLUTE)) {
$sTargetClass = $oAttDef->GetTargetClass(EXTKEY_ABSOLUTE);
$oNewFilter = new DBObjectSearch($sTargetClass);
$oNewFilter->AddConditionAdvanced($sSubSpec, $value);
$this->AddCondition_PointingTo($oNewFilter, $sAttCode);
} else {
throw new Exception("Attribute specification '{$sAttSpec}', '{$sAttCode}' should be either a link set or an external key");
}
} else {
// $sAttSpec is an attribute code
//
if (is_array($value)) {
$oField = new FieldExpression($sAttSpec, $this->GetClass());
$oListExpr = ListExpression::FromScalars($value);
$oInValues = new BinaryExpression($oField, 'IN', $oListExpr);
$this->AddConditionExpression($oInValues);
} else {
$this->AddCondition($sAttSpec, $value);
}
}
}