Elgg\Database\EntityTable::getGuidBasedWhereSql PHP Method

getGuidBasedWhereSql() public method

Returns SQL where clause for owner and containers.
public getGuidBasedWhereSql ( string $column, null | array $guids ) : false | string
$column string Column name the guids should be checked against. Usually best to provide in table.column format.
$guids null | array Array of GUIDs.
return false | string
    public function getGuidBasedWhereSql($column, $guids)
    {
        // short circuit if nothing requested
        // 0 is a valid guid
        if (!$guids && $guids !== 0) {
            return '';
        }
        // normalize and sanitise owners
        if (!is_array($guids)) {
            $guids = array($guids);
        }
        $guids_sanitized = array();
        foreach ($guids as $guid) {
            if ($guid !== ELGG_ENTITIES_NO_VALUE) {
                $guid = sanitise_int($guid);
                if (!$guid) {
                    return false;
                }
            }
            $guids_sanitized[] = $guid;
        }
        $where = '';
        $guid_str = implode(',', $guids_sanitized);
        // implode(',', 0) returns 0.
        if ($guid_str !== false && $guid_str !== '') {
            $where = "({$column} IN ({$guid_str}))";
        }
        return $where;
    }