WP_CLI\Utils

esc_like()WP-CLI 1.0

First half of escaping for LIKE special characters % and _ before preparing for MySQL.

Use this only before wpdb::prepare() or esc_sql(). Reversing the order is very bad for security.

Copied from core "wp-includes/wp-db.php". Avoids dependency on WP 4.4 wpdb.

No Hooks.

Return

String. Text in the form of a LIKE phrase. The output is not SQL safe. Call $wpdb::prepare() or real_escape next.

Usage

esc_like( $text );
$text(string) (required)
The raw text to be escaped. The input typed by the user should have no extra or deleted slashes.

esc_like() code WP-CLI 2.8.0-alpha

function esc_like( $text ) {
	return addcslashes( $text, '_%\\' );
}