dimanche 25 novembre 2018

Error on production Database [] Not configured

I recently got this error when tried to create second connection in production, i set this in database,

'second' => [
        'driver' => 'mysql',
        'host' => env('DB_HOST_SECOND', '127.0.0.1'),
        'port' => env('DB_PORT_SECOND', '3306'),
        'database' => env('DB_DATABASE_SECOND', 'forge'),
        'username' => env('DB_USERNAME_SECOND', 'forge'),
        'password' => env('DB_PASSWORD_SECOND', ''),
        'unix_socket' => env('DB_SOCKET', ''),
        'charset' => 'utf8mb4',
        'collation' => 'utf8mb4_unicode_ci',
        'prefix' => '',
        'strict' => false,
        'engine' => null,
    ],

and this in .env

DB_HOST_SECOND=
DB_PORT_SECOND=3360
DB_DATABASE_SECOND=
DB_USERNAME_SECOND=
DB_PASSWORD_SECOND=

And I tried to run this code,

$obj_syarat_skp = DB::connection('second')
                        ->table('tb_transaksi_skp')
                        ->leftJoin('tb_skp', 'tb_skp.id_skp', '=', 'tb_transaksi_skp.id_skp')
                        ->where('tb_skp.id_unsur', '117') //117 untuk pkkmb, rubah ini jika ada perubahan
                        ->where('tb_skp.id_tingkat', '3') //3 fakultas klo g salah
                        ->where('tb_skp.id_partisipasi', '3') //4 g tahu apa ini
                        ->where('nim', $mahasiswa->nim)
                        ->select('id_transaksi', 'bukti', 'validBEM')
                        ->first();

and i got this error

[2018-11-26 12:21:21] production.ERROR: Database [second] not configured. {"exception":"[object] (InvalidArgumentException(code: 0): Database [second] not configured. at /var/www/clients/client5/web331/web/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php:140)

[stacktrace]

can anyone point where i did wrong, and what are the solutions? Is there anything I need to add in production server? By the way, everything I did in localhost running well.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire