加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – 如何在Mongo中按日期和日期范围查询

发布时间:2020-12-13 13:08:46 所属栏目:PHP教程 来源:网络整理
导读:这相当于这个SQL语句? Select * from example WHERE date = '2011-09-21' 该记录与MongoDate字段一起存储. 我还想知道查询之间的语法. This would be the equivalent of this SQL statement? Select * from example WHERE date = ‘2011-09-21’ db.example
这相当于这个SQL语句?
Select * from example WHERE date = '2011-09-21'

该记录与MongoDate字段一起存储.

我还想知道查询之间的语法.

This would be the equivalent of this SQL statement?

Select * from example WHERE date = ‘2011-09-21’

db.example.find({date: dateobject});

对于MongoDB PHP,您将需要使用[MongoDate] [2]类来表示这些日期.其他语言驱动程序通常只使用语言日期构造.

I would also like to know the syntax of the between query.

MongoDB没有between子句.

要使用“大于”,您需要使用其中一个查询运算符.有关详情,请参见here.简单的例子:

db.example.find({ date: { $gt: lowdate,$lt: highdate } });

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读