我有一个收藏,我收藏的一部分在这里,
让我们称之为第一个数组
$ho = array( 'a' =>
array (
'0' => '508bef9e6803fa6305000000',
'1' => '50901eac6803fafb0d000000',
'2' => '508bf3766803fa810f000000',
'3' => '50a2aeac6803fa150b000000',
'4' => '50a2ae846803fa140b000000',
'5' => '50a2ae616803fab706000000',
'6' => '50a2ae3a6803fab506000000',
'7' => '50a2adfc6803fab306000000',
)),
并且还有另一个来自另一个用户的嵌入数组,让我们调用这个第二个数组
'_id' => new MongoId("508bef9e6803fa6305000000"),
'a' =>
array (
'0' => '508bf3766803fa810f000000',
'1' => '50a2ae616803fab706000000',
'2' => '50a2aeac6803fa150b000000',
),
我想做的是从第一个数组中减去第二个数组,但我想用 mongodb
'a' =>
array (
'0' => '508bef9e6803fa6305000000',
'1' => '50901eac6803fafb0d000000',
'4' => '50a2ae846803fa140b000000',
'6' => '50a2ae3a6803fab506000000',
'7' => '50a2adfc6803fab306000000',
),
我尝试了不同的查询,但无法得到这样的结果,谢谢您的帮助:)
$lk = $m->kud->user->findOne(
array(
"_id" => new MongoId("508bef9e6803fa6305000000"),'$nin'=>array("a"=>$ho["a"])
),
array("_id" => 0, "a" => 1)
);