Prefix table Yii2 Gii

I always configured the table prefix - for this message, you can say that my prefix abc_. So in common\config\main-local.php. I have:

'components' => [
'db' => [
    'class' => 'yii\db\Connection',
    'dsn' => 'mysql:host=localhost;dbname=database',
    'username' => 'user',
    'password' => 'pwd',
    'charset' => 'utf8',
    'tablePrefix' => 'abc_',
],
...

I worked on Yii1 and used gii to create models. In this version, it generates files such as: table.php.

Now I work with Yii2 and recognize the differences: giicreate type files abc_table.php. Yes. I checked "Use table prefix".

This is not normal, because the prefix must be transparent. Can someone tell me what I am doing wrong?

+4
source share
1 answer

AbcTest Test. Use Table Prefix. Gii :

class Test extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%test}}';
    }
    ...
}

tableName '{{%test}}', Use Table Prefix. Use Table Prefix , 'abc_test'.

+4

All Articles