Function __global->get_keyset_pagination_settings

Definitions

sources/templates_pagination.php

  • Get SQL pagination parameters taking into account the potential for keyset-pagination.
  • Visibility: public
  • Is abstract?: No
  • Is static?: No
  • Is final?: No
  • Returns: array

Parameters

Name Type Passed by reference? Variadic? Default Set Range Description
$max_name string No No required parameter N/A N/A GET parameter for max results
$max_default integer No No required parameter N/A N/A Default max results value
$start_name string No No required parameter N/A N/A GET parameter for start position
$compound_name ?string No No Null N/A N/A GET parameter name that includes a JSON-encoded combination of $max/$start/$sort/$keyset_param (null: no combo param)
$sort_name ?string No No Null N/A N/A GET parameter for sort order (null: no URL parameter for sorting or no sorting)
$sort_default ?string No No Null N/A N/A Default sort order (null: no sorting)
$sort_filter_func ?string No No Null N/A N/A Function to turn sort parameter into actual database field SQL plus a keyset field parameter [see get_forum_sort_order function as an example] (null: none). This can also be used to define an important security filter, so you should always use it.

Returns

  • A tuple Max to select, Start position, SQL sort order, SQL to append for where clause, SQL to append as order clause, True start position (ignores keyset pagination), Compound parameter, Keyset field name so that we can extract values from DB result sets
  • Type: array
  • Set: N/A
  • Range: N/A

Preview

Code (PHP)

/**
 * Get SQL pagination parameters taking into account the potential for keyset-pagination.
 *
 * @param  string $max_name GET parameter for max results
 * @param  integer $max_default Default max results value
 * @param  string $start_name GET parameter for start position
 * @param  ?string $compound_name GET parameter name that includes a JSON-encoded combination of $max/$start/$sort/$keyset_param (null: no combo param)
 * @param  ?string $sort_name GET parameter for sort order (null: no URL parameter for sorting or no sorting)
 * @param  ?string $sort_default Default sort order (null: no sorting)
 * @param  ?string $sort_filter_func Function to turn sort parameter into actual database field SQL plus a keyset field parameter [see get_forum_sort_order function as an example] (null: none). This can also be used to define an important security filter, so you should always use it.
 * @return array A tuple Max to select, Start position, SQL sort order, SQL to append for where clause, SQL to append as order clause, True start position (ignores keyset pagination), Compound parameter, Keyset field name so that we can extract values from DB result sets
 */

function get_keyset_pagination_settings(string $max_name, int $max_default, string $start_name, ?string $compound_name = null, ?string $sort_name = null, ?string $sort_default = null, ?string $sort_filter_func = null) : array