jeudi 25 février 2016

If condition issue in mongodb

I have a problem with "if condition" in mongodb. I use php here. I have two fields complete_date and available_date. Now I use the below code

$obj = $this->mongo_db;
$obj->where(array('status' => 'y'));        
$obj = $obj->where_between("complete_date",$arr['filter_from'],$arr['filter_to']);      
$res = $obj->get('school');

My need is to change the complete_date and available_date fields in the above where_between condition based on a condition. Below is my condition,

if(complete_date < current_date) then use the complete_date else use the available_date

how to implement this if condition in the above mongodb query?

Aucun commentaire:

Enregistrer un commentaire