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_fields()

Description

Returns a list of fields with refs matching the supplied field refs.

Parameters

ColumnTypeDefaultDescription
$field_refs array Array of field refs
$order_by_passed_refs bool false
order_by_passed_refs bool Returns the array of fields in the order requested in $field_refs

Return

array

Location

include/resource_functions.php lines 7492 to 7530

Definition

 
function get_fields($field_refsbool $order_by_passed_refs false)
{
    if (!
is_array($field_refs)) {
        
trigger_error("\$field_refs passed to get_fields() is not an array.");
    }

    if (
count($field_refs) === 0) {
        return array();
    }

    
$fields ps_query("
        SELECT " 
columns_in("resource_type_field""rtf") . ", t.name AS tab_name
          FROM resource_type_field rtf
          LEFT JOIN tab t ON t.ref=rtf.tab          
         WHERE rtf.ref IN (" 
ps_param_insert(count($field_refs)) . ")
      ORDER BY rtf.order_by"
ps_param_fill($field_refs"i"), "schema");

    
$return = array();   

    if (
$order_by_passed_refs) {

        
$fields_array array_column($fieldsnull'ref');

        foreach (
$field_refs as $field_ref) {
            if (
array_key_exists($field_ref$fields_array) && metadata_field_view_access($field_ref)) {
                
$return[] = $fields_array[$field_ref];
            }
        }

    } else {
        foreach (
$fields as $field) {
            if (
metadata_field_view_access($field['ref'])) {
                
$return[] = $field;
            }
        }
    }

    return 
$return;
}

This article was last updated 15th February 2025 20:35 Europe/London time based on the source file dated 14th February 2025 12:25 Europe/London time.