Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test functions

get_related_keywords()

Description

Retrieves keywords related to a given keyword reference.

This function checks a cache for related keywords associated with the provided
keyword reference. If not found in the cache, it queries the database for related
keywords. The relationship can be one-way or bidirectional based on the
configuration. It returns an array of related keyword references.

Parameters

ColumnTypeDefaultDescription
$keyref int The reference ID of the keyword for which to find related keywords.

Return

array An array of related keyword references.

Location

include/search_functions.php lines 2775 to 2795

Definition

 
function get_related_keywords($keyref)
{
    
debug_function_call("get_related_keywords"func_get_args());

    
# For a given keyword reference returns the related keywords
    # Also reverses the process, returning keywords for matching related words
    # and for matching related words, also returns other words related to the same keyword.
    
global $keyword_relationships_one_way$related_keywords_cache;

    if (isset(
$related_keywords_cache[$keyref])) {
        return 
$related_keywords_cache[$keyref];
    } else {
        if (
$keyword_relationships_one_way) {
            
$related_keywords_cache[$keyref] = ps_array("SELECT related value FROM keyword_related WHERE keyword = ?", array("i"$keyref),"keywords_related");
            return 
$related_keywords_cache[$keyref];
        } else {
            
$related_keywords_cache[$keyref] = ps_array("SELECT keyword value FROM keyword_related WHERE related = ? UNION SELECT related value FROM keyword_related WHERE (keyword = ? OR keyword IN (SELECT keyword value FROM keyword_related WHERE related = ?)) AND related <> ?", array("i"$keyref"i"$keyref"i"$keyref"i"$keyref),"keywords_related");
            return 
$related_keywords_cache[$keyref];
        }
    }
}

This article was last updated 17th November 2024 15:35 Europe/London time based on the source file dated 8th November 2024 11:45 Europe/London time.