Function __global->_check_sizes

Definitions

sources/database_helper.php

  • Check a set of fields aren't going to exceed key limits.
  • Visibility: public
  • Is abstract?: No
  • Is static?: No
  • Is final?: No
  • Returns: bool

Parameters

Name Type Passed by reference? Variadic? Default Set Range Description
$table_name ID_TEXT No No required parameter N/A N/A The table name
$primary_key boolean No No required parameter N/A N/A Whether this will be in a primary key
$fields array No No required parameter N/A N/A The fields (a map between field name and field type [field type must start '*' if it is to be counted])
$id_name ID_TEXT No No required parameter N/A N/A The name of what we are checking (only used to generate clear error messages)
$skip_size_check boolean No No False N/A N/A Whether to skip the size check for the table (only do this for addon modules that don't need to support anything other than MySQL)
$skip_null_check boolean No No False N/A N/A Whether to skip the check for NULL string fields
$save_bytes ?boolean No No False N/A N/A Whether to use lower-byte table storage, with trade-offs of not being able to support all unicode characters; use this if key length is an issue (null: autodetect)
$return_on_error boolean No No False N/A N/A Whether to return on errors

Returns

  • Whether the size limit is not exceeded
  • Type: boolean
  • Set: N/A
  • Range: N/A

Preview

Code (PHP)

/**
 * Check a set of fields aren't going to exceed key limits.
 *
 * @param  ID_TEXT $table_name The table name
 * @param  boolean $primary_key Whether this will be in a primary key
 * @param  array $fields The fields (a map between field name and field type [field type must start '*' if it is to be counted])
 * @param  ID_TEXT $id_name The name of what we are checking (only used to generate clear error messages)
 * @param  boolean $skip_size_check Whether to skip the size check for the table (only do this for addon modules that don't need to support anything other than MySQL)
 * @param  boolean $skip_null_check Whether to skip the check for NULL string fields
 * @param  ?boolean $save_bytes Whether to use lower-byte table storage, with trade-offs of not being able to support all unicode characters; use this if key length is an issue (null: autodetect)
 * @param  boolean $return_on_error Whether to return on errors
 * @return boolean Whether the size limit is not exceeded
 */

function _check_sizes(string $table_name, bool $primary_key, array $fields, string $id_name, bool $skip_size_check = false, bool $skip_null_check = false, ?bool $save_bytes = false, bool $return_on_error = false) : bool