WP_CLI\Utils
esc_sql_ident()
Escapes (backticks) MySQL identifiers (aka schema object names) - i.e. column names, table names, and database/index/alias/view etc names. See https://dev.mysql.com/doc/refman/5.5/en/identifiers.html
No Hooks.
Return
String|Array
. An escaped string if given a string, or an array of escaped strings if given an array of strings.
Usage
esc_sql_ident( $idents );
- $idents(string|array) (required)
- A single identifier or an array of identifiers.
esc_sql_ident() esc sql ident code WP-CLI 2.8.0-alpha
function esc_sql_ident( $idents ) { $backtick = static function ( $v ) { // Escape any backticks in the identifier by doubling. return '`' . str_replace( '`', '``', $v ) . '`'; }; if ( is_string( $idents ) ) { return $backtick( $idents ); } return array_map( $backtick, $idents ); }