1

2 つのテーブル es_user と es_user_detail があり、user.id = user_detail.user_id の関係です。

application/config/database.php ファイルでプレフィックス「es_」を定義しました。

$db['default']['dbprefix'] = 'es_';

今、一度に2つのテーブルを更新するコードを書きました

$this->db->set('us.prefix',$this->input->post('prefix',TRUE));
$this->db->set('us.first_name',$this->input->post('first_name',TRUE));            
$this->db->set('us.last_name',$this->input->post('last_name',TRUE));
$this->db->set('us.gender',$this->input->post('gender',TRUE));

$this->db->set('us.email',$this->input->post('email',TRUE));
$this->db->set('ud.home_number',$this->input->post('home_number',TRUE));
$this->db->set('ud.mobile_number',$this->input->post('mobile_number',TRUE));
$this->db->set('ud.address',$this->input->post('address',TRUE));
$this->db->set('ud.address1',$this->input->post('address1',TRUE));

$this->db->set('ud.state',$this->input->post('state',TRUE));
$this->db->set('ud.zip',$this->input->post('zip',TRUE));
$this->db->set('ud.country',$this->input->post('country',TRUE));
$this->db->set('ud.work_job_title',$this->input->post('work_job_title',TRUE));
$this->db->set('ud.work_company',$this->input->post('work_company',TRUE));
$this->db->set('ud.work_address',$this->input->post('work_address',TRUE));
$this->db->set('ud.work_city',$this->input->post('work_city',TRUE));
$this->db->set('ud.work_state',$this->input->post('work_state',TRUE));
$this->db->set('ud.work_country',$this->input->post('work_country',TRUE));
$this->db->set('ud.work_website',$this->input->post('work_website',TRUE));
$this->db->set('ud.email_update_notify',$this->input->post('email_update_notify',TRUE));



$this->db->set('ud.email_event_notify',$this->input->post('email_event_notify',TRUE));
$this->db->set('us.last_modify_date',$this->general->get_local_time('time'));
$this->db->where("user_id", $this->session->userdata(SESSION.'user_id'));
$this->db->where("us.id = ud.user_id");
$this->db->update('user as us, user_detail as ud');

テーブルの更新に失敗しました。ここから得たエラーは次のとおりです。

Table 'es_ems.user_detail' doesn't exist

UPDATE `es_user` as us, user_detail as ud SET `es_us`.`prefix` = 'mr', `es_us`.`first_name` = 'xyz', `es_us`.`last_name` = 'abc', `es_us`.`gender` = 'm', `es_us`.`email` = 'xyz@gmail.com', `es_ud`.`home_number` = '898939958', `es_ud`.`mobile_number` = '9841844058', `es_ud`.`address` = 'chabahil', `es_ud`.`address1` = 'ason', `es_ud`.`state` = 0, `es_ud`.`zip` = '01234', `es_ud`.`country` = 'country', `es_ud`.`work_job_title` = 'PHP Developer', `es_ud`.`work_company` = 'pqr company', `es_ud`.`work_address` = 'work address', `es_ud`.`work_city` = 'city', `es_ud`.`work_state` = 'state ', `es_ud`.`work_country` = 'country', `es_ud`.`work_website` = 'http://www.pqr.com', `es_ud`.`email_update_notify` = '1', `es_ud`.`email_event_notify` = '1', `es_us`.`last_modify_date` = '2013-03-18 13:46:22' WHERE `user_id` = '6' AND `es_us`.`id` = ud.user_id

Filename: D:\wamp\www\ems\system\database\DB_driver.php
4

1 に答える 1