[php-src] Issue #11331: can we get a PDO::quoteIdentifier ?

From: Date: Sun, 28 May 2023 12:03:23 +0000
Subject: [php-src] Issue #11331: can we get a PDO::quoteIdentifier ?
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-244556@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/11331 Author: divinity76 ### Description for example on MySQL it would be something like ``` function quoteIdentifier(string $identifier, string $charset = "UTF-8"): string { $identifierCharInCharset = mb_convert_encoding("`", $charset, "UTF-8"); return $identifierCharInCharset . strtr( $identifier, [ $identifierCharInCharset => $identifierCharInCharset . $identifierCharInCharset ] ) . $identifierCharInCharset; } ``` ... for the sake of readability, a charset-ignorant implementation would look like ``` function quoteIdentiferNaive(string $identifier): string { return '' . strtr($identifier, ['' => '`']) . ''; } ``` (* at my job i always use UTF-8 and have the naive version running in production)

« previous php.bugs (#244556) next »