wpdb::process_field_charsets() protected WP 4.2.0
Adds field charsets to field/value/format arrays generated by wpdb::process_field_formats().
{} It's a method of the class: wpdb{}
No Hooks.
Return
Array/false. The same array as $data with additional 'charset' keys. False on failure.
Usage
// protected - for code of main (parent) or child class $result = $this->process_field_charsets( $data, $table );
- $data(array) (required)
- As it comes from the wpdb::process_field_formats() method.
- $table(string) (required)
- Table name.
Changelog
Since 4.2.0 | Introduced. |
Code of wpdb::process_field_charsets() wpdb::process field charsets WP 5.6
protected function process_field_charsets( $data, $table ) {
foreach ( $data as $field => $value ) {
if ( '%d' === $value['format'] || '%f' === $value['format'] ) {
/*
* We can skip this field if we know it isn't a string.
* This checks %d/%f versus ! %s because its sprintf() could take more.
*/
$value['charset'] = false;
} else {
$value['charset'] = $this->get_col_charset( $table, $field );
if ( is_wp_error( $value['charset'] ) ) {
return false;
}
}
$data[ $field ] = $value;
}
return $data;
}