classSetNames
final class SetNames
implements SetItem
uses Snapshot
@visibility public.SET NAMES: sets the client, connection and result character sets, and the connection collation.
Rule: MYSQL-SET-NAMES-001. SET NAMES cs [COLLATE co] sets character_set_client, character_set_connection and character_set_results to cs and collation_connection to co, or to the default collation of cs; SET NAMES DEFAULT maps the three to the default character set. The character set and collation are names the server resolves; the context holds no character set catalog, so a collation of another character set (ER_COLLATION_CHARSET_MISMATCH) is not detected. Facts: none. Terminates: the parts are leaves. Source: https://dev.mysql.com/doc/refman/8.4/en/set-names.html. Status: Implemented.
$set = (new \SqlSemantics\Platform\MySql\Semantics())->analyze("SET NAMES 'utf8mb4' COLLATE utf8mb4_bin");
[$set->statement->items[0]->charset->name?->value, $set->statement->items[0]->collation?->name?->value, $set->toString()] // => ['utf8mb4', 'utf8mb4_bin', 'SET NAMES utf8mb4 COLLATE utf8mb4_bin']Properties§
public CharsetName $charsetpublic CollationName|null $collation = nullMethods§
public function __construct(
public CharsetName $charset,
public CollationName|null $collation = null,
)Parameters
$charset | CharsetName | The character set, or DEFAULT |
$collation | CollationName|null | The collation of the connection; MySQL 5.x also accepts COLLATE DEFAULT |
public function deriveItem(Derivation $derivation): voidDerives nothing: the names are resolved by the server.
Parameters
$derivation | Derivation |
public function render(Output $out): voidWrites NAMES, the character set and the collation.
Parameters
$out | Output |
Calls 1
- method-call Output::keyword() line 56
Test cases 1§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.