wpdb::_escape() WordPress Method

The wpdb::_escape() method is a WordPress function that escapes a string for use in a SQL query. It is used to prepare data for insertion into a database table.

wpdb::_escape( string|array $data ) #

Escapes data. Works on arrays.


Parameters

$data

(string|array)(Required)Data to escape.


Top ↑

Return

(string|array) Escaped data, in the same type as supplied.


Top ↑

Source

File: wp-includes/wp-db.php

	public function _escape( $data ) {
		if ( is_array( $data ) ) {
			foreach ( $data as $k => $v ) {
				if ( is_array( $v ) ) {
					$data[ $k ] = $this->_escape( $v );
				} else {
					$data[ $k ] = $this->_real_escape( $v );
				}
			}
		} else {
			$data = $this->_real_escape( $data );
		}

		return $data;
	}


Top ↑

Changelog

Changelog
VersionDescription
2.8.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.