Jump to content
Larry Ullman's Book Forums

How To Use Join In Cgridview

Recommended Posts

Hello guys, how are you ?
I have three tables "A", "B" and "C", all the tables have 'name' fields, now I am saving the "B" and "C"'s table data in table "A" such that I am changing the field display property using javascript and can save both the tables i.e. "B" and "C" data in either field. Now In "A"'s admin gridview I want to display both fields data that I have stored in "A" table and it displays the ids of all those records. Now I want to display the 'name' of the records of "B" and "C"'s tables instead of their ids. So how can I do this ?

One option is to use Joins and Unions. But I don't have that concept.

Please anyone who knows the solution help me ?

Thanks in advance. 

Link to post
Share on other sites

I don't recall the exact syntax offhand, but you can use the defined relation to have Yii load this for you. Basically, instead of specifying that you want property `something` from table A (i.e., the current model), you'd request `relationName.otherTableColumn`. 

Link to post
Share on other sites

Thanks Larry for your reply.

Actually I have to fields and two models data, and I am switching the fields and in both the fields both models data can be saved. 

So when in cgridview, I want to display that two fields data, then I want to display the name fields data instead of id. Now in both of fields, both models data is saved, so how can I classify that data regarding to their model ?

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...