function drupal_schema_get_field_value

Typecasts values to proper data types.

MySQL PDO silently casts, e.g. FALSE and '' to 0, when inserting the value into an integer column, but PostgreSQL PDO does not. Look up the schema information and use that to correctly typecast the value.

Parameters

array $info: An array describing the schema field info.

mixed $value: The value to be converted.

Return value

mixed The converted value.

Deprecated

in drupal:8.8.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema::castValue() instead.

See also

https://www.drupal.org/node/3051983

Related topics

1 call to drupal_schema_get_field_value()
SchemaLegacyTest::testSchemaGetFieldValue in core/tests/Drupal/KernelTests/Core/Database/SchemaLegacyTest.php
Tests deprecation of the drupal_schema_get_field_value() function.

File

core/includes/schema.inc, line 226

Code

function drupal_schema_get_field_value(array $info, $value) {
    @trigger_error('drupal_schema_get_field_value() is deprecated in drupal:8.8.0. It will be removed from drupal:9.0.0. Use \\Drupal\\Core\\Entity\\Sql\\SqlContentEntityStorageSchema::castValue($info, $value) instead. See https://www.drupal.org/node/3051983', E_USER_DEPRECATED);
    return SqlContentEntityStorageSchema::castValue($info, $value);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.