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

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -