这是我试图通过活动记录实现的查询:
UPDATE `Customer_donations` cd
join Invoices i on i.cd_id = cd.cd_id
set cd.amount = '4', cd.amount_verified = '1'
WHERE i.invoice_id = '13';
这是我对活动记录的尝试:
$data = array('cd.amount'=>$amount, 'cd.amount_verified'=>'1');
$this->db->join('Invoices i', 'i.cd_id = cd.cd_id')
->where('i.invoice_id', $invoiceId);
// update the table with the new data
if($this->db->update('Customer_donations cd', $data)) {
return true;
}
这是实际生成的查询:
UPDATE `Customer_donations` cd
SET `cd`.`amount` = '1', `cd`.`amount_verified` = '1'
WHERE `i`.`invoice_id` = '13'
为什么此活动记录语句不应用我的连接子句?
下面的解决方案怎么样?有点难看,但它达到了您在问题中的预期。
$invoiceId = 13;
$amount = 4;
$data = array('cd.amount'=>$amount, 'cd.amount_verified'=>'1');
$this->db->where('i.invoice_id', $invoiceId);
$this->db->update('Customer_donations cd join Invoices i on i.cd_id = cd.cd_id', $data);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)