wpdb::process_field_formats( array $data, mixed $format )

Prepares arrays of value/format pairs as passed to wpdb CRUD methods.


Parameters

$data

(Required) Array of fields to values.

$format

(Required) Formats to be mapped to the values in $data.


Return

(array) Array, keyed by field names with values being an array of 'value' and 'format' keys.


Source

File: wp-includes/wp-db.php

	protected function process_field_formats( $data, $format ) {
		$formats = $original_formats = (array) $format;

		foreach ( $data as $field => $value ) {
			$value = array(
				'value'  => $value,
				'format' => '%s',
			);

			if ( ! empty( $format ) ) {
				$value['format'] = array_shift( $formats );
				if ( ! $value['format'] ) {
					$value['format'] = reset( $original_formats );
				}
			} elseif ( isset( $this->field_types[ $field ] ) ) {
				$value['format'] = $this->field_types[ $field ];
			}

			$data[ $field ] = $value;
		}

		return $data;
	}


Changelog

Changelog
Version Description
WP-4.2.0 Introduced.