开发者

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;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜