我在github上浏览了yii2-oauth2-server代码,在migration file中遇到了有趣的语法。 。有问题的代码如下所示:
$this->createTable('{{%oauth_clients}}', [
...
], $tableOptions);
有人可以解释一下{{%oauth_clients}}
部分吗? {{%..}}
中包含表名是什么意思? official documentation on migrations对此什么也没说,所有示例都有这样的“原始”表名称:
$this->createTable('post_tag', [
...
]);
我检查了我的数据库,该表已创建,就好像没有括号一样,它的名称只是oauth_clients
。
最佳答案
用于表前缀
来自 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}}
.
关于Yii2 迁移。表名中的百分号和括号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38698129/