yii2yii2-modelguid-partition-table

How to partition table on Yii2?


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.


Solution

  • Change the related model

    the tableName function return the table name

    class YouModel  extends \yii\db\ActiveRecord
    {
    
        public static function tableName()
        {
            return 'yourTableName' . $YourNumber ;
        }
        ......