开发者

Codeigniter setting multiple where conditions, how to unset one

开发者 https://www.devze.com 2022-12-29 22:19 出处:网络
I\'ve got a script that is a notify_url from paypal that is supposed to update multiple tables in my database using the following code:

I've got a script that is a notify_url from paypal that is supposed to update multiple tables in my database using the following code:

//update first table

$this->db->where('someid', $somid);

$this->db开发者_运维问答->update('table', $data);

///update second table

$this->db->where('somesecondid', $somesecondid)

$this->db->update('anothertable', $data2);

Then I get the following error: Unknown column 'somesecondid' in 'where clause'

UPDATE anothertable SET avail = 0 WHERE someid = '13' AND somesecondid = '199'

So codeigniter is combining those where clauses into a single query. Is there a way to unset the first one so it only has "UPDATE anothertable SET avail=0 WHERE somesecondid = 199" ? Thanks!


You might want to look into Active Record Caching in the user_guide...
http://codeigniter.com/user_guide/database/active_record.html#caching
Maybe you have '$this->db->start_cache()' somewhere earlier in your code.


Currently, I'm unable to replicate your error. I'm successfully running two update statements as you have them above.

As an alternative, you can pass the WHERE clause information directly to $this->db->update() using an array (per the CodeIgniter Active Record documentation) like this:

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

精彩评论

暂无评论...
验证码 换一张
取 消