保存

2012-07-26 45 views
1

我有一個小問題,節省人POST領域到MongoDB的保存

function savedata($data){ 
     $collection = $this->db->retail_logs; 
     $this->data = json_decode($data); 


     try { 
     $collection->update(
      array("tradingname"=>$this->data['tradingname']), 
      $this->data, "date"=> date("d.m.Y"), "time"=>date("H:i:s"),"whochanged"=>$_COOKIE['CRMUIDkey']), // new lead document to insert 
      array("upsert" => true, "safe" => true) 
      ); 
     } catch (Exception $e) { 
      // Something went wrong .. 
     } 
    } 

對於一些振振有辭的$這個 - 所有的POST信息的MongoDB>持有的$ _ POST並不想去那裏我得到這個數據錯誤

Warning: json_decode() expects parameter 1 to be string, array given in /home/crmvip/public_html/system/db/mongo.php on line 294 

Warning: MongoCollection::update() expects at most 3 parameters, 4 given in /home/crmvip/public_html/system/db/mongo.php on line 302 

它發送POST信息像它應該tradingname=monkey&street=abc

回答

1

json_decode是用於解碼JSON。

$this->data = $_POST['data']; 

如果你只是想保存的data值通過POST請求接收