0
我有一個客戶希望獲得合作伙伴提供的一系列產品,但他們需要批准更改。保留合作伙伴變更歷史的最佳方法是什麼?使用MongoDB獲得批准/正在申請
因此,這裏是如何工作的
{
partner_id: {here}
offer1:
offer2:
offer3:
date:
status:
}
我需要一種方法來檢查是否有任何報價變化(但只有1回),如果改變插入,使過去一個作爲狀態:歷史
有隻應該永遠是以下狀態:
歷史
待定
批准
但是如果他們插入新的報價,但有一個批准的報價,那麼它需要保持批准狀態,直到我們批准爲止。
我該怎麼做?這是我想:
<?php
function checkoffers($data)
{
$this->data = $data;
$collection = $this->db->partner_offers;
if($this->data["_id"] != null)
{
$cursor = $collection->insert(RUN INSERT ARRAY)
}
else
{
$cursor = $collection->find(array("_id"=>new MongoId($this->data["_id"])));
if ($cursor->count() > 0)
{
$test = array();
while($cursor->hasNext()) {
$test[] = ($cursor->getNext());
}
foreach($test as $offers)
{
check to see if offer matches the past offer. if not then run new function and insert.
}
}
}
?>