PMA\libraries\Util::getDefaultFunctionForField PHP Method

getDefaultFunctionForField() public static method

Returns default function for a particular column.
public static getDefaultFunctionForField ( array $field, boolean $insert_mode ) : string
$field array Data about the column for which to generate the dropdown
$insert_mode boolean Whether the operation is 'insert'
return string An HTML snippet of a dropdown list with function names appropriate for the requested column.
    public static function getDefaultFunctionForField($field, $insert_mode)
    {
        /*
         * @todo Except for $cfg, no longer use globals but pass as parameters
         *       from higher levels
         */
        global $cfg, $data;
        $default_function = '';
        // Can we get field class based values?
        $current_class = $GLOBALS['PMA_Types']->getTypeClass($field['True_Type']);
        if (!empty($current_class)) {
            if (isset($cfg['DefaultFunctions']['FUNC_' . $current_class])) {
                $default_function = $cfg['DefaultFunctions']['FUNC_' . $current_class];
            }
        }
        // what function defined as default?
        // for the first timestamp we don't set the default function
        // if there is a default value for the timestamp
        // (not including CURRENT_TIMESTAMP)
        // and the column does not have the
        // ON UPDATE DEFAULT TIMESTAMP attribute.
        if ($field['True_Type'] == 'timestamp' && $field['first_timestamp'] && empty($field['Default']) && empty($data) && $field['Extra'] != 'on update CURRENT_TIMESTAMP' && $field['Null'] == 'NO') {
            $default_function = $cfg['DefaultFunctions']['first_timestamp'];
        }
        // For primary keys of type char(36) or varchar(36) UUID if the default
        // function
        // Only applies to insert mode, as it would silently trash data on updates.
        if ($insert_mode && $field['Key'] == 'PRI' && ($field['Type'] == 'char(36)' || $field['Type'] == 'varchar(36)')) {
            $default_function = $cfg['DefaultFunctions']['FUNC_UUID'];
        }
        return $default_function;
    }
Util