Saving Data In Other Table

Hi

am new to yii and i dont know how to save data in second table after insert in first table…

I want to insert one form value and first table id in second table

My table structures is


My user table is

CREATE TABLE IF NOT EXISTS user (

id int(10) unsigned NOT NULL AUTO_INCREMENT,

username varchar(100) NOT NULL,

password varchar(100) NOT NULL,

fullname varchar(200) NOT NULL,

role varchar(200) NOT NULL,

created_by varchar(25) NOT NULL,

created_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,

modified_by int(11) NOT NULL,

status char(10) NOT NULL,

clientid varchar(25) NOT NULL,

modified_date timestamp NOT NULL DEFAULT ‘0000-00-00 00:00:00’,

PRIMARY KEY (id)

) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=106 ;

my client table is

CREATE TABLE IF NOT EXISTS user_client_map (

id int(10) unsigned NOT NULL AUTO_INCREMENT,

user_id int(11) NOT NULL,

client_id int(11) NOT NULL,

PRIMARY KEY (id)

) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=28 ;

from THE FORM WE TAKE CLIENT ID AND SAVE DATA IN USER AFTER SAVING DATA IN USER TABLE WE SAVE THAT USER.ID AND CLIENTID FROM FORM SAVE TO user_client_map TABLE…

I DONT KNOW HOW TO MAP PLEASE GIVE SOLUTION FOR THIS ISSUE

THANX IN ADVANCE


Google is your friend: Search 'yii 2 models one form

Gave me this