我正在使用官方的 C# mongodb 驱动程序,它确实支持 LINQ。但是我在尝试将其转换为使用 php 驱动程序时遇到了麻烦。
这是 LINQ 查询:
.Where(c => DateTime.UtcNow.Subtract(c.DateRequested).TotalDays <= 14).Where(d => ((d.itemid == req.itemid) && (d.MediaType == req.MediaType)) && (d.Status != RequestStatus.Cancelled))
我不是 100% 确定我是否正确地处理这个问题,但这是我迄今为止以可读格式进行的尝试:
Array
(
[$and] => Array
(
[DateRequested] => Array
(
[$gt] => MongoDate Object
(
[sec] => 1341754027
[usec] => 0
)
[$lte] => MongoDate Object
(
[sec] => 1342963627
[usec] => 0
)
)
[$and] => Array
(
[$and] => Array
(
[itemid] => 76510
[MediaType] => 0
)
[Account] => Josh
)
[Status] => Array
(
[$ne] => 3
)
)
)
这是凌乱的形式:
array('$and' => array('DateRequested' => array('$gt' => new MongoDate((time() - 1209600)), '$lte' =>new MongoDate(time())),'$and' => array('$and' => array('itemid' => $itemid,'MediaType' => $source),'Account' => $account),'Status' => array('$ne' => 3)))