我知道這個問題已經被問到,但我似乎在實施目前正在處理的項目中的解決方案時遇到問題。我試圖更新CodeIgniter中的兩個表,但框架的escape()數據庫函數似乎做錯了事情。下面是代碼片段很努力:在CodeIgniter中更新多個表格
public function update_taxpayer($usertin, $data){
$this->usid = $usertin;
if($this->verify_user_tin($this->usid)){
$this->db->set($data);
$this->db->where('t.taxpayer_id','tp.id');
$this->db->where('t.tin', $usertin);
$this->db->update("tin AS t, taxpayer AS tp");
$updated_rows = $this->db->affected_rows();
}
}
,同時試圖從我的控制器運行更新我得到這個錯誤:
Error Number: 1146
Table 'crsirs.tin as t, taxpayer' doesn't exist
UPDATE `tin AS t, taxpayer` AS `tp` SET `t`.`address` = '', `t`.`name` = 'MAPS PROJECT CROSS RIVER STATE', `tp`.`lastModified` = '2016-06-07 13:54:27', `tp`.`city` = '', `tp`.`email` = '', `tp`.`mobile` = '', `tp`.`phone` = NULL WHERE `t`.`taxpayer_id` = 'tp.id' AND `t`.`tin` = '1902406349-0001'
Filename: C:/Program Files/wamp/www/CRSIRS/system/database/DB_driver.php
Line Number: 691
的escape()函數似乎是合併這兩個表作爲這一行中的一個tin AS t, taxpayer
,似乎沒有妥善逃避它們。請問我該如何解決這個問題?
我知道我可以實現我希望通過交易實現的目標,但我固執的自我並不想這麼做! – aknessy
什麼版本的CodeIgniter? – eggyal
@eggyal我目前使用CodeIgniter 3.0.6 – aknessy