vendredi 25 mai 2018

$slice operator of mongoDB not working in PHP

I have got this mongoDB query db.b_activity.find({token_id:"71e32267108b163ccdd3f59ba06c66674b295499"},{activity_log:{$slice: -1}}).pretty(); .

It gets all the desired results in the mongoDB terminal. But when i write the same query in PHP , it fetches the complete array every time .

MY PHP query $get_current_activity=$this->mongo_b_employee->b_activity->findOne(array('token_id'=>$token_id),array("activity_log" => array('$slice' => -1)));..

Any suggestions where i am going wrong .

PS: i am just trying to access the last array element.




Aucun commentaire:

Enregistrer un commentaire