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) Returns an array of fields that contain paired values and formats. Returns 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

Changelog
Version Description
WP-4.2.0 Introduced.