我现在迷路了。
这就是我所拥有的:
$criteria = new \EMongoCriteria();
$criteria->userId = new \MongoID($userId);
$criteria->expiresAt = array('>' => new \MongoDate(time()));
然后我正在运行这个:
$model->count($criteria);
当我知道有符合此标准的文档时,它总是返回0。 有什么想法吗?
更新
具有相同标准的 findAllByAttributes()
完美无缺。但我不需要那些我需要计算的文件。
答案 0 :(得分:1)
将条件字段设置为属性时,它使用简单的比较(field == value
)。您应该通过调用字段设置此条件,如下所示:
$criteria->expiresAt('>', new \MongoDate(time()));
注意:错误地将条件传递给findAllByAttributes
,它不适用于EMongoCriteria
,而是使用简单数组。如果要使用条件对象,请将其传递给findAll
方法。