Edward Posted May 2, 2012 Share Posted May 2, 2012 When a user signs up to my website the information taken from the registration page needs to be put into 3 separate tables, a users table, user_status table and a user address table, how can such a situation be done using yii, when you can generate only one controller per model? I am also rerunning over the SQL stuff and would like to practice doing TABLE JOINS, how can such be done using Yii? Link to comment Share on other sites More sharing options...
Antonio Conte Posted May 2, 2012 Share Posted May 2, 2012 Table joins are very easy in Yii by the look of it. A simple google search for 'yii query' gave me this link: http://www.yiiframework.com/doc/guide/1.1/en/database.query-builder You would do something like this: $user = Yii::app()->db->createCommand() ->select('id, username, profile') ->from('tbl_user u') ->join('tbl_profile p', 'u.id = p.user_id') ->join('tbl_another o', 'u.another_id = o.another_id') ->join('tbl_mother m', 'u.mother_id = m.mother_id') ->where('id=:id', array(':id'=>$id)) ->queryRow() Never used Yii, but a simple google search can solve most of your problems. 1 Link to comment Share on other sites More sharing options...
Edward Posted May 2, 2012 Author Share Posted May 2, 2012 Yes it was Google i did first run a search in, but intially searched for "Yii Table Joins" nothing came up with nothing that was helpful. I see your search on Yii query brought up some better results, yes i guess it is a query. I also checked my books but didn't find anything much in there, so that's why i was asking here for a pointer. Thanks for your help AC. Link to comment Share on other sites More sharing options...
Recommended Posts