Collections functions
General functions
Render functions
Theme permission functions
Resource functions

update_fieldx()

Description

updates the value of fieldx field further to a metadata field value update

Parameters

ColumnTypeDefaultDescription
$metadata_field_ref integer - metadata field ref

Return

array

Location

include/metadata_functions.php lines 339 to 369

Definition

 
function update_fieldx(int $metadata_field_ref)
    {
    global 
$NODE_FIELDS;

    
$joins=get_resource_table_joins();  // returns an array of field refs  
    
if($metadata_field_ref && (in_array($metadata_field_ref,$joins)))
        {
        
$fieldinfo get_resource_type_field($metadata_field_ref);
        
$allresources ps_array("SELECT ref value FROM resource WHERE ref>0 ORDER BY ref ASC", []);
        if(
in_array($fieldinfo['type'],$NODE_FIELDS))
                {
                foreach(
$allresources as $resource)
                    {
                    
$resnodes get_resource_nodes($resource$metadata_field_reftrue);
                    
$resvals array_column($resnodes,"name");
                    
$resdata implode(",",$resvals);
                    
$value truncate_join_field_value(strip_leading_comma($resdata));
                    
ps_query("update resource set field" $metadata_field_ref "= ? where ref= ?", ['s'$value'i'$resource]);
                    }
                }
        else
                {
                foreach(
$allresources as $resource)
                    {
                    
$resdata get_data_by_field($resource,$metadata_field_ref);
                    
$value truncate_join_field_value(strip_leading_comma($resdata));
                    
ps_query("update resource set field" $metadata_field_ref "= ? where ref= ?", ['s'$value'i'$resource]);
                    }
                }
         }
    }

This article was last updated 4th October 2022 11:05 Europe/London time based on the source file dated 5th July 2022 12:30 Europe/London time.