问题
I browsed the yii2-oauth2-server code on github and encountered interesting syntax in the migration file. The code in question looks like this:
$this->createTable('{{%oauth_clients}}', [
...
], $tableOptions);
Can someone explain the {{%oauth_clients}} part? What does it mean when the table name is enclosed in {{%..}}? The official documentation on migrations says nothing about it and all examples have the "raw" table names like this:
$this->createTable('post_tag', [
...
]);
I checked my database and the table was created as if there were no brackets, its name is simply oauth_clients.
回答1:
Is used for table prefix
From yii2 documentation on Db connection:
If a table name is given as
{{%TableName}}, then the percentage character%will be replaced with this property value. For example,{{%post}}becomes{{tbl_post}}.
来源:https://stackoverflow.com/questions/38698129/yii2-migrations-percentage-sign-and-brackets-in-table-name