Yii Framework Forum: Saving Data In Other Table - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Saving Data In Other Table Rate Topic: -----

#1 User is offline   kareem 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 09-May 14

Posted 11 May 2014 - 05:34 AM

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


----
0

#2 User is offline   jkofsky 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 535
  • Joined: 17-May 10
  • Location:Pensacola, Florida

Posted 11 May 2014 - 11:27 PM

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

Gave me this
Do, or do not. There is no 'try.' Jedi Master Yoda
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users