CodeIgniter Forums

Full Version: insert data into 2 table
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i wanna ask you for all of the expertttt in CI, i've got a problem, i have a form that contain "id_diskon". I want to insert that "id_diskon" attribute into two different table,  which is table diskon and table diskon tunai. in table diskon, "id_diskon" is a primary key and in table diskon tunai, "id diskon"is a primary key foreign key, so this is an "is a" case in erd diagram. my question is, can you guys tell me the query for the model and controller to run that form, because when i run in my text editor, i've always got an error message like this picture above.
In order to insert the primary key of table diskon into table diskon_tunai, codeIgniter has built in helper functions to help with this task.
PHP Code:
//prepare data for table diskon    
$data = array(
  'content' => 'My content',
//insert into table diskon

//prepare data for table diskon_tunai
$data = array(
  'id_diskon' => $this->db->insert_id(),
//insert into table diskon_tunai