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

Processes arrays of field/value pairs and field formats.


Description 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 Parameters

$table

(string) (Required) Table name.

$data

(array) (Required) Field/value pair.

$format

(mixed) (Required) Format for each field.


Top ↑

Return Return

(array|false) Returns an array of fields that contain paired values and formats. Returns false for invalid values.


Top ↑

Source 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;
	}

Top ↑

Changelog Changelog

Changelog
Version Description
4.2.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.