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.
Returns
String|Array
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.13.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 );
}