Update function in multiple database connections in same laravel app

Posted 1 year ago by Thameera
 $db_ext = \DB::connection('mysql2');
 $countries = $db_ext->table('kotitems')->get();
        print_r($countries);die;

here i update to second database but this works fine but when i use update function' like

$db_ext->table('kotitems')->where('id',$items->name) ->update(['item_unit'=>$remain]);

it searches in database 1 and pass error message as kot.table not found but it needs to serch in scs database i can read from second database but cant write in to it,but i can't connect the table through model if it is it will be ok.

Please sign in or create an account to participate in this conversation.