Typecasts values to proper datatypes.
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.
array $info: An array describing the schema field info.
mixed $value: The value to be converted.
mixed The converted value.
function drupal_schema_get_field_value(array $info, $value) {
if ($info['type'] == 'int' || $info['type'] == 'serial') {
$value = (int) $value;
}
elseif ($info['type'] == 'float') {
$value = (double) $value;
}
else {
$value = (string) $value;
}
return $value;
}