php mongodb find - 返回计算值
在 PHP 中 -> MongoDB,如何返回字段作为计算值?
$this->Collection = $this->db->$theDB;
$cursor = $this->Collection->find();
例如,我的字段之一是出生日期:
DOB : 1/1/1980
相反,我想取回 AGE。当前日期 - 出生日期 = 年龄。
这可能/如何?
In PHP -> MongoDB, how do I return a field as a calculated value?
$this->Collection = $this->db->$theDB;
$cursor = $this->Collection->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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以执行 map-reduce 并像这样处理年龄
You could do a map-reduce and process the age like that
不,这是不可能的。
只创建一个从 dob 返回你年龄的方法怎么样?
No, it is not possible.
How about just create method that will return to you age from dob?