laravel queue usage problem: multi-database configuration
阿神
阿神 2017-05-16 16:49:08
0
1
508

Using asynchronous queue, when configuring the database, I have two databases mysql and mysql2 in config/database.php:

        'mysql' => [
            'driver'    => 'mysql',
            'host'      => env('DB_HOST', 'localhost'),
            'database'  => env('DB_DATABASE', 'forge'),
            ...
        ],

        'mysql2' => [
            'driver'    => 'mysql',
            'host'      => env('DB_O2O_HOST', 'localhost'),
            'database'  => env('DB_O2O_DATABASE', 'forge'),
            ...
        ],

I put the jobs table of the queue in mysql2. When adding tasks to the queue, the default connection is mysql. Can this be configured? ##config/queue.php To specify the connected database?

阿神
阿神

闭关修行中......

reply all(1)
大家讲道理

In the modelconstructor of the table, show the call

   public function __construct() {
        $this->setConnection('mysql2');
        parent::__construct();
    }
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!