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

get_tabs_with_usage_count()

Description

Get tabs (paged) based on some criteria (currently only order by and limit).

Parameters

ColumnTypeDefaultDescription
$criteria array Array holding criteria information (order_by and limit).

Return

array {@see sql_limit_with_total_count()}

Location

include/tab_functions.php lines 43 to 66

Definition

 
function get_tabs_with_usage_count(array $criteria)
    {
    
$order_by = isset($criteria['order_by'][0]) && in_array($criteria['order_by'][0], ['order_by''ref'])
                ? 
$criteria['order_by'][0]
                : 
'order_by';
    
$sort = isset($criteria['order_by'][1]) && validate_sort_value($criteria['order_by'][1])
            ? 
$criteria['order_by'][1]
            : 
'ASC';

    
$per_page $criteria['limit']['per_page'] ?? null;
    
$offset $criteria['limit']['offset'] ?? null;

    
$query = new PreparedStatementQuery(
        
"SELECT t.ref,
                t.`name`,
                t.order_by,
                (SELECT count(ref) FROM resource_type_field WHERE tab = t.ref) AS usage_rtf,
                (SELECT count(ref) FROM resource_type WHERE tab = t.ref) AS usage_rt
           FROM tab AS t
           ORDER BY 
{$order_by} {$sort}"
    
);

    return 
sql_limit_with_total_count($query$per_page$offset);
    }

This article was last updated 22nd July 2024 21:35 Europe/London time based on the source file dated 16th May 2024 18:10 Europe/London time.