Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

How To Fetch User Table Id Value Into Another Table

$
0
0
Hi, I've three tables in my database namely user, preferences and questions. My preferences table is like this..

CREATE TABLE IF NOT EXISTS `preferences` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`questionid` int(11) DEFAULT NULL,
`answers` varchar(100) DEFAULT NULL,
`user_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `questionid` (`questionid`),
KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

My questions table is like this

CREATE TABLE IF NOT EXISTS `questions` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`question` varchar(400) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

I given foreign keys to preferences table to questionid from questions table id and user_id from user table id. Now i'm inserting answers values into preferences. Can i know how to fetch questionid and user_id into preferences table. My questions are in _form.php file.


Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>