wpdb::_real_escape( string $data ): string

Real escape using mysqli_real_escape_string().


Description

Top ↑

See also


Top ↑

Parameters

$data string Required
String to escape.

Top ↑

Return

string Escaped string.


Top ↑

Source

File: wp-includes/class-wpdb.php. View all references

public function _real_escape( $data ) {
	if ( ! is_scalar( $data ) ) {
		return '';
	}

	if ( $this->dbh ) {
		$escaped = mysqli_real_escape_string( $this->dbh, $data );
	} else {
		$class = get_class( $this );

		wp_load_translations_early();
		/* translators: %s: Database access abstraction class, usually wpdb or a class extending wpdb. */
		_doing_it_wrong( $class, sprintf( __( '%s must set a database connection for use with escaping.' ), $class ), '3.6.0' );

		$escaped = addslashes( $data );
	}

	return $this->add_placeholder_escape( $escaped );
}


Top ↑

Changelog

Changelog
Version Description
2.8.0 Introduced.

Top ↑

User Contributed Notes

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