php - Facing issue while reusing mongo connection -
i have 'employees' collection
i'm creating new mongo connection using following code
$mongoobject = db::connection('mongodb')->collection('employees'); //fetch employee employee id $employee = $mongoobject->where('employee_id', $input['employee_id'])->first(); //fetch employees $employees = $mongoobject->get();
now problem got first response when tried fetch employees using same mongo connection gives 1 record. per understanding it's not flushing conditions after use ->first() of eloquent.
is there way reuse same mongo connection using eloquent methods?
thanks.
after calling first() limit being set 1 why returns 1 record.
following code works:-
$mongoobject = db::connection('mongodb')->collection('employees'); //fetch employee employee id $employee = $mongoobject->where('employee_id', $input['employee_id'])->first(); //fetch employees $employees = $mongoobject->newquery()->from('employees')->get();
Comments
Post a Comment