本文整理汇总了PHP中DBObjectSearch::GetCriteria_FullText方法的典型用法代码示例。如果您正苦于以下问题:PHP DBObjectSearch::GetCriteria_FullText方法的具体用法?PHP DBObjectSearch::GetCriteria_FullText怎么用?PHP DBObjectSearch::GetCriteria_FullText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBObjectSearch
的用法示例。
在下文中一共展示了DBObjectSearch::GetCriteria_FullText方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: MakeQuery
private static function MakeQuery(&$oBuild, DBObjectSearch $oFilter, $aAttToLoad = null, $aValues = array(), $bIsMainQueryUNUSED = false)
{
// Note: query class might be different than the class of the filter
// -> this occurs when we are linking our class to an external class (referenced by, or pointing to)
$sClass = $oFilter->GetFirstJoinedClass();
$sClassAlias = $oFilter->GetFirstJoinedClassAlias();
$bIsOnQueriedClass = array_key_exists($sClassAlias, $oBuild->GetRootFilter()->GetSelectedClasses());
self::DbgTrace("Entering: " . $oFilter->ToOQL() . ", " . ($bIsOnQueriedClass ? "MAIN" : "SECONDARY"));
$sRootClass = self::GetRootClass($sClass);
$sKeyField = self::DBGetKey($sClass);
if ($bIsOnQueriedClass) {
// default to the whole list of attributes + the very std id/finalclass
$oBuild->m_oQBExpressions->AddSelect($sClassAlias . 'id', new FieldExpression('id', $sClassAlias));
if (is_null($aAttToLoad) || !array_key_exists($sClassAlias, $aAttToLoad)) {
$aAttList = self::ListAttributeDefs($sClass);
} else {
$aAttList = $aAttToLoad[$sClassAlias];
}
foreach ($aAttList as $sAttCode => $oAttDef) {
if (!$oAttDef->IsScalar()) {
continue;
}
// keep because it can be used for sorting - if (!$oAttDef->LoadInObject()) continue;
foreach ($oAttDef->GetSQLExpressions() as $sColId => $sSQLExpr) {
$oBuild->m_oQBExpressions->AddSelect($sClassAlias . $sAttCode . $sColId, new FieldExpression($sAttCode . $sColId, $sClassAlias));
}
}
// Transform the full text condition into additional condition expression
$aFullText = $oFilter->GetCriteria_FullText();
if (count($aFullText) > 0) {
$aFullTextFields = array();
foreach (self::ListAttributeDefs($sClass) as $sAttCode => $oAttDef) {
if (!$oAttDef->IsScalar()) {
continue;
}
if ($oAttDef->IsExternalKey()) {
continue;
}
$aFullTextFields[] = new FieldExpression($sAttCode, $sClassAlias);
}
$oTextFields = new CharConcatWSExpression(' ', $aFullTextFields);
foreach ($aFullText as $sFTNeedle) {
$oNewCond = new BinaryExpression($oTextFields, 'LIKE', new ScalarExpression("%{$sFTNeedle}%"));
$oBuild->m_oQBExpressions->AddCondition($oNewCond);
}
}
}
//echo "<p>oQBExpr ".__LINE__.": <pre>\n".print_r($oBuild->m_oQBExpressions, true)."</pre></p>\n";
$aExpectedAtts = array();
// array of (attcode => fieldexpression)
//echo "<p>".__LINE__.": GetUnresolvedFields($sClassAlias, ...)</p>\n";
$oBuild->m_oQBExpressions->GetUnresolvedFields($sClassAlias, $aExpectedAtts);
// Compute a clear view of required joins (from the current class)
// Build the list of external keys:
// -> ext keys required by an explicit join
// -> ext keys mentionned in a 'pointing to' condition
// -> ext keys required for an external field
// -> ext keys required for a friendly name
//
$aExtKeys = array();
// array of sTableClass => array of (sAttCode (keys) => array of (sAttCode (fields)=> oAttDef))
//
// Optimization: could be partially computed once for all (cached) ?
//
if ($bIsOnQueriedClass) {
// Get all Ext keys for the queried class (??)
foreach (self::GetKeysList($sClass) as $sKeyAttCode) {
$sKeyTableClass = self::$m_aAttribOrigins[$sClass][$sKeyAttCode];
$aExtKeys[$sKeyTableClass][$sKeyAttCode] = array();
}
}
// Get all Ext keys used by the filter
foreach ($oFilter->GetCriteria_PointingTo() as $sKeyAttCode => $aPointingTo) {
if (array_key_exists(TREE_OPERATOR_EQUALS, $aPointingTo)) {
$sKeyTableClass = self::$m_aAttribOrigins[$sClass][$sKeyAttCode];
$aExtKeys[$sKeyTableClass][$sKeyAttCode] = array();
}
}
$aFNJoinAlias = array();
// array of (subclass => alias)
if (array_key_exists('friendlyname', $aExpectedAtts)) {
// To optimize: detect a restriction on child classes in the condition expression
// e.g. SELECT FunctionalCI WHERE finalclass IN ('Server', 'VirtualMachine')
$oNameExpression = self::GetExtendedNameExpression($sClass);
$aNameFields = array();
$oNameExpression->GetUnresolvedFields('', $aNameFields);
$aTranslateNameFields = array();
foreach ($aNameFields as $sSubClass => $aFields) {
foreach ($aFields as $sAttCode => $oField) {
$oAttDef = self::GetAttributeDef($sSubClass, $sAttCode);
if ($oAttDef->IsExternalKey()) {
$sClassOfAttribute = self::$m_aAttribOrigins[$sSubClass][$sAttCode];
$aExtKeys[$sClassOfAttribute][$sAttCode] = array();
} elseif ($oAttDef->IsExternalField() || $oAttDef instanceof AttributeFriendlyName) {
$sKeyAttCode = $oAttDef->GetKeyAttCode();
$sClassOfAttribute = self::$m_aAttribOrigins[$sSubClass][$sKeyAttCode];
$aExtKeys[$sClassOfAttribute][$sKeyAttCode][$sAttCode] = $oAttDef;
} else {
$sClassOfAttribute = self::GetAttributeOrigin($sSubClass, $sAttCode);
}
//.........这里部分代码省略.........