【问题标题】:Codeigniter setting multiple where conditions, how to unset oneCodeigniter设置多个where条件,如何取消设置一个
【发布时间】:2010-05-12 19:48:26
【问题描述】:

我有一个脚本,它是来自 paypal 的 notify_url,它应该使用以下代码更新我的数据库中的多个表:

//更新第一个表
$this->db->where('someid', $somid);
$this->db->update('table', $data);
///更新第二张表
$this->db->where('somesecondid', $somesecondid)
$this->db->update('anothertable', $data2);

然后我收到以下错误:'where 子句'中的未知列'somesecondid'

更新anothertable SET avail = 0 其中someid = '13' 和somesecondid = '199'


所以 codeigniter 将那些 where 子句组合成一个查询。有没有办法取消设置第一个,所以它只有“UPDATE anothertable SETavail=0 WHERE somesecondid = 199”?谢谢!

【问题讨论】:

    标签: mysql codeigniter where-clause


    【解决方案1】:

    您可能想在 user_guide 中查看 Active Record 缓存...
    http://codeigniter.com/user_guide/database/active_record.html#caching
    也许你在代码的前面有'$this->db->start_cache()'。

    【讨论】:

      【解决方案2】:

      目前,我无法复制您的错误。我成功地运行了两个更新语句,就像你在上面所说的那样。

      作为替代方案,您可以使用这样的数组(根据CodeIgniter Active Record documentation)将WHERE 子句信息直接传递给$this->db->update()

      $this->db->update('table', $data, array('someid' => $someid));
      $this->db->update('anothertable', $data2, array('somesecondid' => $somesecondid));
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-05-19
        • 2013-01-01
        • 1970-01-01
        • 2018-11-29
        • 2013-06-16
        • 2020-12-16
        • 2012-09-19
        相关资源
        最近更新 更多