Update function in multiple database connections in same laravel app $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.
I got the ans i did by using eloquent model and connect the second database through it
class Item extends Eloquent
{
protected $connection = 'mysql2';
use SoftDeletes;
protected $dates = ['deleted_at'];
protected $table = 'kotitems';
public $fillable = ['item_code','item_name','item_unit','min_level','meassure'];
}
Please sign in or create an account to participate in this conversation.