how to create more pages and link them

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!!!!!

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

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…

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

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.

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.

You can redirect user after the create action has successfully created the user.

Like this:

[PHP]

$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'


	)));


}

}

[/PHP]

Thanks a lot…