Dynamically change database connection in cakephp 3

后端 未结 3 1059
耶瑟儿~
耶瑟儿~ 2021-01-24 02:36

I\'m trying to change the database connection used in cakephp 3 on the fly. Every answer to this question that I found refers to cakephp 2 (The

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-24 03:16

    Configuring table connections

     namespace App\Model\Table;
    
     use Cake\ORM\Table;
    
     class ArticlesTable extends Table
     {
         public static function defaultConnectionName() {
         return 'replica_db';
         }
     }
    

提交回复
热议问题