Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource functions

update_resource_type_field_resource_types()

Description

Update the resource_type_field - resource_type mappings

Parameters

ColumnTypeDefaultDescription
$ref int Resource type field ref
$resource_types array Array of resource type refs

Return

void *

Location

include/config_functions.php lines 1463 to 1479

Definition

 
function update_resource_type_field_resource_types(int $ref,array $resource_types)
    {
    
ps_query("DELETE FROM resource_type_field_resource_type WHERE resource_type_field = ?",["i",$ref]);
    if(
in_array(0,$resource_types))
        {
        
// Global field, cannot have specific fields assigned
        
ps_query("UPDATE resource_type_field SET global=1 WHERE ref = ?",["i",$ref]);
        }
    elseif(
count($resource_types)>0)
        {
        
$query "INSERT INTO resource_type_field_resource_type (resource_type_field, resource_type) VALUES ";
        
$valuestring "(" . (int)$ref . (str_repeat(",?),(" $ref,count($resource_types)-1)) . ",?)";
        
ps_query($query .$valuestring,ps_param_fill($resource_types,"i"));
        
ps_query("UPDATE resource_type_field SET global=0 WHERE ref = ?",["i",$ref]);
        }
    
clear_query_cache("schema");
    }

This article was last updated 29th May 2024 08:35 Europe/London time based on the source file dated 23rd May 2024 18:05 Europe/London time.