wpdb::add_placeholder_escape() WordPress Method

The wpdb::add_placeholder_escape() method is a helper method for safely adding placeholder values to SQL queries. Placeholder values are replaced with the corresponding real values when the query is executed, and this method ensures that the placeholder values are properly escaped for safe use in a SQL query.

wpdb::add_placeholder_escape( string $query ) #

Adds a placeholder escape string, to escape anything that resembles a printf() placeholder.


Parameters

$query

(string)(Required)The query to escape.


Top ↑

Return

(string) The query with the placeholder escape string inserted where necessary.


Top ↑

Source

File: wp-includes/wp-db.php

	public function add_placeholder_escape( $query ) {
		/*
		 * To prevent returning anything that even vaguely resembles a placeholder,
		 * we clobber every % we can find.
		 */
		return str_replace( '%', $this->placeholder_escape(), $query );
	}


Top ↑

Changelog

Changelog
VersionDescription
4.8.3Introduced.

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.