Welcome Guest, Not a member yet? Register   Sign In
insert data into 2 table

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.

Attached Files Thumbnail(s)

(This post was last modified: 12-27-2016, 09:49 PM by suhindra.)

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

Theme © iAndrew 2016 - Forum software by © MyBB