1
我使用官方的C#mongodb驅動程序,並且它具有LINQ支持。但我無法嘗試將其轉換爲使用PHP驅動程序。將LINQ查詢轉換爲php mongodb查詢格式
這是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)))
謝謝。我不知道它使用「和」隱含的那樣。 回答tumbleweed問題的額外點! – Josh 2012-08-28 08:08:23