【问题标题】:how to update a json data in sql threw php如何通过php更新sql中的json数据
【发布时间】:2016-03-15 17:58:47
【问题描述】:

我正在处理一个表单,我必须在 sql 中以 Json 格式插入数据。 插入完成。现在问题是更新。

这是我在 codeigniter 中的更新模型:

public function Update()
            {
                print("<pre>");
                    print_r($_POST);
                    print_r($_REQUEST['Userid']);
                    print("</pre>");
                $jsonData = json_encode($_POST);
                $data2 = array(

                    'form_data' => $jsonData
                );


                $this->db->where($_REQUEST['Userid']);
                $this->db->update('form',$data2);
                return;
            }

我的sql表有两个字段:(1)id(2)form 在表单中,我以 json 格式存储所有表单数据。我在表单页面上获取数据,但没有更新。

【问题讨论】:

    标签: php sql json codeigniter


    【解决方案1】:
    $this->db->where($_REQUEST['Userid']);
    

    应该是

    $this->db->where('id',$_REQUEST['Userid']);`
    

    您的where 子句中缺少column 参数

    【讨论】:

      猜你喜欢
      • 2019-02-24
      • 2016-02-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-20
      • 2018-06-22
      相关资源
      最近更新 更多