How to partition table on Yii2?

827 Views Asked by At

A table named demo,now need to partition it just like demo1,demo2,demo3,....,demo10

So how to partition the table on Yii2?

I probably known should add a method getTableName in Model.

1

There are 1 best solutions below

5
On BEST ANSWER

Change the related model

the tableName function return the table name

class YouModel  extends \yii\db\ActiveRecord
{

    public static function tableName()
    {
        return 'yourTableName' . $YourNumber ;
    }
    ......