wpdb::process_fields( string $table, array $data, mixed $format )

Processes arrays of field/value pairs and field formats.

Description

This is a helper method for wpdb’s CRUD methods, which take field/value pairs for inserts, updates, and where clauses. This method first pairs each value with a format. Then it determines the charset of that field, using that to determine if any invalid text would be stripped. If text is stripped, then field processing is rejected and the query fails.

Parameters

$table

(string) (Required) Table name.

$data

(array) (Required) Field/value pair.

$format

(mixed) (Required) Format for each field.

Return

(array|false) An array of fields that contain paired value and formats. False for invalid values.

Source

File: wp-includes/wp-db.php

protected function process_fields( $table, $data, $format ) {
		$data = $this->process_field_formats( $data, $format );
		if ( false === $data ) {
			return false;
		}

		$data = $this->process_field_charsets( $data, $table );
		if ( false === $data ) {
			return false;
		}

		$data = $this->process_field_lengths( $data, $table );
		if ( false === $data ) {
			return false;
		}

		$converted_data = $this->strip_invalid_text( $data );

		if ( $data !== $converted_data ) {
			return false;
		}

		return $data;
	}

Changelog

Version Description
4.2.0 Introduced.

© 2003–2021 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wpdb/process_fields