保存所有POST信息mongodb

时间:2012-07-26 02:22:57

标签: mongodb post

我有一个小问题,将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 .. 
        }
    }

对于一些共鸣,$ this->持有$ _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

它会像tradingname=monkey&street=abc

那样发送POST信息

1 个答案:

答案 0 :(得分:1)

json_decode用于解码JSON。

如果您只想保存通过POST请求收到的data的值:

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