php mongodb find - return calculated value
In PHP -> MongoDB, how do I return a field as a calculated value?
$this->Collection = $this->db->$theDB;
$cursor = $this->Collection-&g开发者_开发问答t;find();
For example, one of my fields is date of birth:
DOB : 1/1/1980
Instead, I want to get back the AGE. Current Date - DOB = AGE.
Is this possible / how?
You could do a map-reduce and process the age like that
No, it is not possible.
How about just create method that will return to you age from dob?
getAgeFromDOB(date dob)
{
return Current Date - dob;
}
精彩评论