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


PHP SFUtils::getSQLConditionForAutocompleteInColumn方法代码示例

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


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

示例1: getAllValuesForProperty

 private static function getAllValuesForProperty($property_name, $substring, $basePropertyName = null, $baseValue = null)
 {
     global $sfgMaxAutocompleteValues, $sfgCacheAutocompleteValues, $sfgAutocompleteCacheTimeout;
     global $smwgDefaultStore;
     $values = array();
     $db = wfGetDB(DB_SLAVE);
     $sqlOptions = array();
     $sqlOptions['LIMIT'] = $sfgMaxAutocompleteValues;
     $property = SMWPropertyValue::makeUserProperty($property_name);
     $propertyHasTypePage = $property->getPropertyTypeID() == '_wpg';
     $property_name = str_replace(' ', '_', $property_name);
     $conditions = array('p_ids.smw_title' => $property_name);
     // Use cache if allowed
     if ($sfgCacheAutocompleteValues) {
         $cache = SFFormUtils::getFormCache();
         // Remove trailing whitespace to avoid unnecessary database selects
         $cacheKeyString = $property_name . '::' . rtrim($substring);
         if (!is_null($basePropertyName)) {
             $cacheKeyString .= ',' . $basePropertyName . ',' . $baseValue;
         }
         $cacheKey = wfMemcKey('sf-autocomplete', md5($cacheKeyString));
         $values = $cache->get($cacheKey);
         if (!empty($values)) {
             // Return with results immediately
             return $values;
         }
     }
     if ($propertyHasTypePage) {
         $valueField = 'o_ids.smw_title';
         if ($smwgDefaultStore === 'SMWSQLStore3') {
             $idsTable = $db->tableName('smw_object_ids');
             $propsTable = $db->tableName('smw_di_wikipage');
         } else {
             $idsTable = $db->tableName('smw_ids');
             $propsTable = $db->tableName('smw_rels2');
         }
         $fromClause = "{$propsTable} p JOIN {$idsTable} p_ids ON p.p_id = p_ids.smw_id JOIN {$idsTable} o_ids ON p.o_id = o_ids.smw_id";
     } else {
         if ($smwgDefaultStore === 'SMWSQLStore3') {
             $valueField = 'p.o_hash';
             $idsTable = $db->tableName('smw_object_ids');
             $propsTable = $db->tableName('smw_di_blob');
         } else {
             $valueField = 'p.value_xsd';
             $idsTable = $db->tableName('smw_ids');
             $propsTable = $db->tableName('smw_atts2');
         }
         $fromClause = "{$propsTable} p JOIN {$idsTable} p_ids ON p.p_id = p_ids.smw_id";
     }
     if (!is_null($basePropertyName)) {
         $baseProperty = SMWPropertyValue::makeUserProperty($basePropertyName);
         $basePropertyHasTypePage = $baseProperty->getPropertyTypeID() == '_wpg';
         $basePropertyName = str_replace(' ', '_', $basePropertyName);
         $conditions['base_p_ids.smw_title'] = $basePropertyName;
         if ($basePropertyHasTypePage) {
             if ($smwgDefaultStore === 'SMWSQLStore3') {
                 $idsTable = $db->tableName('smw_object_ids');
                 $propsTable = $db->tableName('smw_di_wikipage');
             } else {
                 $idsTable = $db->tableName('smw_ids');
                 $propsTable = $db->tableName('smw_rels2');
             }
             $fromClause .= " JOIN {$propsTable} p_base ON p.s_id = p_base.s_id";
             $fromClause .= " JOIN {$idsTable} base_p_ids ON p_base.p_id = base_p_ids.smw_id JOIN {$idsTable} base_o_ids ON p_base.o_id = base_o_ids.smw_id";
             $baseValue = str_replace(' ', '_', $baseValue);
             $conditions['base_o_ids.smw_title'] = $baseValue;
         } else {
             if ($smwgDefaultStore === 'SMWSQLStore3') {
                 $baseValueField = 'p_base.o_hash';
                 $idsTable = $db->tableName('smw_object_ids');
                 $propsTable = $db->tableName('smw_di_blob');
             } else {
                 $baseValueField = 'p_base.value_xsd';
                 $idsTable = $db->tableName('smw_ids');
                 $propsTable = $db->tableName('smw_atts2');
             }
             $fromClause .= " JOIN {$propsTable} p_base ON p.s_id = p_base.s_id";
             $fromClause .= " JOIN {$idsTable} base_p_ids ON p_base.p_id = base_p_ids.smw_id";
             $conditions[$baseValueField] = $baseValue;
         }
     }
     if (!is_null($substring)) {
         // "Page" type property valeus are stored differently
         // in the DB, i.e. underlines instead of spaces.
         $conditions[] = SFUtils::getSQLConditionForAutocompleteInColumn($valueField, $substring, $propertyHasTypePage);
     }
     $sqlOptions['ORDER BY'] = $valueField;
     $res = $db->select($fromClause, "DISTINCT {$valueField}", $conditions, __METHOD__, $sqlOptions);
     while ($row = $db->fetchRow($res)) {
         $values[] = str_replace('_', ' ', $row[0]);
     }
     $db->freeResult($res);
     if ($sfgCacheAutocompleteValues) {
         // Save to cache.
         $cache->set($cacheKey, $values, $sfgAutocompleteCacheTimeout);
     }
     return $values;
 }
开发者ID:roland2025,项目名称:mediawiki-extensions-SemanticForms,代码行数:98,代码来源:SF_AutocompleteAPI.php

示例2: getAllValuesForProperty

 private static function getAllValuesForProperty($property_name, $substring, $base_property_name = null, $base_value = null)
 {
     $values = array();
     $db = wfGetDB(DB_SLAVE);
     $sql_options = array();
     $sql_options['LIMIT'] = 500;
     //$limit;
     $property = SMWPropertyValue::makeUserProperty($property_name);
     $is_relation = $property->getPropertyTypeID() == '_wpg';
     $property_name = str_replace(' ', '_', $property_name);
     $conditions = array('p_ids.smw_title' => $property_name);
     if ($is_relation) {
         $value_field = 'o_ids.smw_title';
         $from_clause = $db->tableName('smw_rels2') . " r JOIN " . $db->tableName('smw_ids') . " p_ids ON r.p_id = p_ids.smw_id JOIN " . $db->tableName('smw_ids') . " o_ids ON r.o_id = o_ids.smw_id";
     } else {
         $value_field = 'a.value_xsd';
         $from_clause = $db->tableName('smw_atts2') . " a JOIN " . $db->tableName('smw_ids') . " p_ids ON a.p_id = p_ids.smw_id";
     }
     if (!is_null($base_property_name)) {
         $base_property = SMWPropertyValue::makeUserProperty($base_property_name);
         $base_is_relation = $base_property->getPropertyTypeID() == '_wpg';
         $base_property_name = str_replace(' ', '_', $base_property_name);
         $conditions['base_p_ids.smw_title'] = $base_property_name;
         $main_prop_alias = $is_relation ? 'r' : 'a';
         if ($base_is_relation) {
             $from_clause .= " JOIN " . $db->tableName('smw_rels2') . " r_base ON {$main_prop_alias}.s_id = r_base.s_id";
             $from_clause .= " JOIN " . $db->tableName('smw_ids') . " base_p_ids ON r_base.p_id = base_p_ids.smw_id JOIN " . $db->tableName('smw_ids') . " base_o_ids ON r_base.o_id = base_o_ids.smw_id";
             $base_value = str_replace(' ', '_', $base_value);
             $conditions['base_o_ids.smw_title'] = $base_value;
         } else {
             $from_clause .= " JOIN " . $db->tableName('smw_atts2') . " a_base ON {$main_prop_alias}.s_id = a_base.s_id";
             $from_clause .= " JOIN " . $db->tableName('smw_ids') . " base_p_ids ON a_base.p_id = base_p_ids.smw_id";
             $conditions['a_base.value_xsd'] = $base_value;
         }
     }
     if (!is_null($substring)) {
         $conditions[] = SFUtils::getSQLConditionForAutocompleteInColumn($value_field, $substring);
     }
     $sql_options['ORDER BY'] = $value_field;
     $res = $db->select($from_clause, "DISTINCT {$value_field}", $conditions, __METHOD__, $sql_options);
     while ($row = $db->fetchRow($res)) {
         $values[] = str_replace('_', ' ', $row[0]);
     }
     $db->freeResult($res);
     return $values;
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:46,代码来源:PracticalPlants_Body.php

示例3: getAllPagesForNamespace

 public static function getAllPagesForNamespace($namespace_name, $substring = null)
 {
     global $wgContLang, $wgLanguageCode;
     // Cycle through all the namespace names for this language, and
     // if one matches the namespace specified in the form, get the
     // names of all the pages in that namespace.
     // Switch to blank for the string 'Main'.
     if ($namespace_name == 'Main' || $namespace_name == 'main') {
         $namespace_name = '';
     }
     $matchingNamespaceCode = null;
     $namespaces = $wgContLang->getNamespaces();
     foreach ($namespaces as $curNSCode => $curNSName) {
         if ($curNSName == $namespace_name) {
             $matchingNamespaceCode = $curNSCode;
         }
     }
     // If that didn't find anything, and we're in a language
     // other than English, check English as well.
     if (is_null($matchingNamespaceCode) && $wgLanguageCode != 'en') {
         $englishLang = Language::factory('en');
         $namespaces = $englishLang->getNamespaces();
         foreach ($namespaces as $curNSCode => $curNSName) {
             if ($curNSName == $namespace_name) {
                 $matchingNamespaceCode = $curNSCode;
             }
         }
     }
     if (is_null($matchingNamespaceCode)) {
         return "Could not find namespace: {$namespace_name}";
     }
     $db = wfGetDB(DB_SLAVE);
     $conditions = array();
     $conditions['page_namespace'] = $matchingNamespaceCode;
     if ($substring != null) {
         $conditions[] = SFUtils::getSQLConditionForAutocompleteInColumn('page_title', $substring);
     }
     $res = $db->select('page', 'page_title', $conditions, __METHOD__, array('ORDER BY' => 'page_title'));
     $pages = array();
     while ($row = $db->fetchRow($res)) {
         $pages[] = str_replace('_', ' ', $row[0]);
     }
     $db->freeResult($res);
     return $pages;
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:45,代码来源:SF_Utils.php

示例4: getAllValuesForProperty

 private static function getAllValuesForProperty($property_name, $substring, $base_property_name = null, $base_value = null)
 {
     global $sfgMaxAutocompleteValues, $sfgCacheAutocompleteValues, $sfgAutocompleteCacheTimeout;
     $values = array();
     $db = wfGetDB(DB_SLAVE);
     $sql_options = array();
     $sql_options['LIMIT'] = $sfgMaxAutocompleteValues;
     $property = SMWPropertyValue::makeUserProperty($property_name);
     $is_relation = $property->getPropertyTypeID() == '_wpg';
     $property_name = str_replace(' ', '_', $property_name);
     $conditions = array('p_ids.smw_title' => $property_name);
     // Use cache if allowed
     if ($sfgCacheAutocompleteValues) {
         $cache = SFFormUtils::getFormCache();
         // Remove trailing whitespace to avoid unnecessary database selects
         $cacheKeyString = $property_name . '::' . rtrim($substring);
         if (!is_null($base_property_name)) {
             $cacheKeyString .= ',' . $base_property_name . ',' . $base_value;
         }
         $cacheKey = wfMemcKey('sf-autocomplete', md5($cacheKeyString));
         $values = $cache->get($cacheKey);
         if (!empty($values)) {
             // Return with results immediately
             return $values;
         }
     }
     if ($is_relation) {
         $value_field = 'o_ids.smw_title';
         $from_clause = $db->tableName('smw_rels2') . " r JOIN " . $db->tableName('smw_ids') . " p_ids ON r.p_id = p_ids.smw_id JOIN " . $db->tableName('smw_ids') . " o_ids ON r.o_id = o_ids.smw_id";
     } else {
         $value_field = 'a.value_xsd';
         $from_clause = $db->tableName('smw_atts2') . " a JOIN " . $db->tableName('smw_ids') . " p_ids ON a.p_id = p_ids.smw_id";
     }
     if (!is_null($base_property_name)) {
         $base_property = SMWPropertyValue::makeUserProperty($base_property_name);
         $base_is_relation = $base_property->getPropertyTypeID() == '_wpg';
         $base_property_name = str_replace(' ', '_', $base_property_name);
         $conditions['base_p_ids.smw_title'] = $base_property_name;
         $main_prop_alias = $is_relation ? 'r' : 'a';
         if ($base_is_relation) {
             $from_clause .= " JOIN " . $db->tableName('smw_rels2') . " r_base ON {$main_prop_alias}.s_id = r_base.s_id";
             $from_clause .= " JOIN " . $db->tableName('smw_ids') . " base_p_ids ON r_base.p_id = base_p_ids.smw_id JOIN " . $db->tableName('smw_ids') . " base_o_ids ON r_base.o_id = base_o_ids.smw_id";
             $base_value = str_replace(' ', '_', $base_value);
             $conditions['base_o_ids.smw_title'] = $base_value;
         } else {
             $from_clause .= " JOIN " . $db->tableName('smw_atts2') . " a_base ON {$main_prop_alias}.s_id = a_base.s_id";
             $from_clause .= " JOIN " . $db->tableName('smw_ids') . " base_p_ids ON a_base.p_id = base_p_ids.smw_id";
             $conditions['a_base.value_xsd'] = $base_value;
         }
     }
     if (!is_null($substring)) {
         $conditions[] = SFUtils::getSQLConditionForAutocompleteInColumn($value_field, $substring);
     }
     $sql_options['ORDER BY'] = $value_field;
     $res = $db->select($from_clause, "DISTINCT {$value_field}", $conditions, __METHOD__, $sql_options);
     while ($row = $db->fetchRow($res)) {
         $values[] = str_replace('_', ' ', $row[0]);
     }
     $db->freeResult($res);
     if ($sfgCacheAutocompleteValues) {
         // Save to cache.
         $cache->set($cacheKey, $values, $sfgAutocompleteCacheTimeout);
     }
     return $values;
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:65,代码来源:SF_AutocompleteAPI.php


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