Yii Framework Forum: how to create more pages and link them - Yii Framework Forum

Jump to content

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

how to create more pages and link them

#1 User is offline   nigilan 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 13-December 11

Posted 28 December 2011 - 10:11 AM

hi all,
i am new to yii, i was developing a site. I have some 19 tables in it. I use CRUD in GII to access the databases, so my doubt is whether i have to create 19 controllers and models to access all the databases?

how can i access two diff tables in single controller??

thanks in advance!!!!!
0

#2 User is offline   yiqing95 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 602
  • Joined: 27-December 10
  • Location:china

Posted 28 December 2011 - 11:21 AM

if your tables are all standalone Entity , may be you should create all models for them (one table need one model class) ,if some of these can't be represented by an Entity( i assume that you are familiar with E_R designing ) you don't need create a model for such table (for example : bridge table just for many_to_many relation, or some table have no obvious primary key).


for the controller , in crud actions you can access any model , the generated code often need to add some additional method to handle complex situations or you need to modify the default generated code . these generated code just a skeleton for you .

please read the wikis for some clues ,there are too many article for that , just give you the latest one
Update two model with one view
0

#3 User is offline   nigilan 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 13-December 11

Posted 31 December 2011 - 01:46 AM

hi, thanks for replying so soon..i dont get this completely, sorry... Now my situation is

consider there are two controllers user and profileData. When i click a menu, it should move from user/index to profileData/create. i have redirected it but the below error is coming..

Error 400

Your request is invalid.
pls help me with this..
0

#4 User is offline   Anita Khanna 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 12-January 12

Posted 12 January 2012 - 03:57 AM

Hi fellow indians even i need a solution to this problem help :(
0

#5 User is offline   mastermunj 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 34
  • Joined: 12-July 11

Posted 23 January 2012 - 03:48 AM

One can use & manipulate as many models as needed via one controller. However, its better to have logical segments to lower maintenance time.

Like user related programming should go under "user" module, client related under "client" module and so on.

If there are common models / classes to be used, they can go under "components" directory altogether to make them available for all modules.

Further if you could elaborate more on your problem statement, a proper solution can be suggested.
0

#6 User is offline   nigilan 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 13-December 11

Posted 23 January 2012 - 04:32 AM

Thanks for the reply, consider i have 2 models, say content and user. After the index page is loaded it will display the user/create page, after 'submit' button is clicked i have to display the content/update page, which is not successful.
0

#7 User is offline   mastermunj 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 34
  • Joined: 12-July 11

Posted 23 January 2012 - 04:44 AM

You can redirect user after the create action has successfully created the user.
Like this:
$model = new ModelName();
if($_POST['submit'])
{
	if($_POST['ModelName'])
	{
		$model->attributes = $_POST['ModelName'];
	}
	if($model->validate())
	{
		$model->save();
		//redirect to other page after saving.
		$this->redirect(array('controller/action', array(
			'param1' => 'param1Value'
		)));
	}
}

0

#8 User is offline   nigilan 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 13-December 11

Posted 23 January 2012 - 06:54 AM

Thanks a lot....
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