【问题标题】:Update table data within Codeigniter Controller / MySQL在 Codeigniter 控制器/MySQL 中更新表数据
【发布时间】:2013-06-28 13:53:31
【问题描述】:

我对这个很感兴趣。我正在使用 Codeigniter 控制器。

我需要更新下面代码中“DATA HERE”所在的订单状态。

基本上这是我需要做的,在名为“orders”的表中找到 $orderid,找到“status”并将其更新为文本“Paid”。

$orderid = $id;

if($this->input->post("status")=="OK" && $this->input->post("step")=="Confirmation" && $this->input->post("orderhash")==$orderHashOrg)
    {
        // DATA HERE    
    }

非常感谢任何帮助。

这是我当前的代码

$updateData=array("status"=>"Paid");

    if($this->input->post("status")=="OK" && $this->input->post("step")=="Confirmation" && $this->input->post("orderhash")==$orderHashOrg)
    {

        $d = $this->db->get('offers_orders');
        $this->db->select('status');
        $this->db->where('order_number', $id);

        $orderdata = $d->result_array();

        $this->db->update("offers_orders", $updateData);

    }

【问题讨论】:

  • 先写你的代码,我们可以帮忙修复bug
  • 刚刚更新...谢谢!

标签: php mysql codeigniter


【解决方案1】:

假设您已经建立了数据库连接。

 $orderid = $id;

if($this->input->post("status")=="OK" && $this->input->post("step")=="Confirmation" && $this->input->post("orderhash")==$orderHashOrg)
{

$updateData=array("status"=>"Paid");

$this->db->where("orderid",$orderid);
$this->db->update("orders",$updateData);    
}

【讨论】:

    【解决方案2】:
    function update ($data,$id){
    
        $this->db->where('user.id',intval($id));
    
        return $this->db->update('user', $data);
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-01-03
      • 1970-01-01
      • 2017-11-21
      • 1970-01-01
      • 2016-07-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多