我正在写这样的查询:-
$data = array(
'company_billing' => "if (company_billing = $userId, (NULL), $userId)",
'company_admin' => "if (company_admin = $userId, (NULL), $userId)",
);
$this->db->where('id', $organizationId);
$this->db->update('organization', $data);
我期待类似的东西:-
UPDATE `organization` SET `organization`.`company_billing` = if (company_billing = 2, (NULL), 2), `organization`.`company_admin` = if (company_admin = 2, (NULL), 2) WHERE `id` = 1
但我得到:-
UPDATE `organization` SET `organization`.`company_billing` = 'if (company_billing = 2, (NULL), 2)', `organization`.`company_admin` = 'if (company_admin = 2, (NULL), 2)' WHERE `id` = 1
如果条件块,我想跳过那些引号。
有什么方法可以实现这一点,否则我将不得不编写本机查询?
谢谢