Get Table Row In Model Raltions


I’m currently confronted with a problem of Model relation. I need to make a Relation who relates to an other Table value.

Something like(This one don’t work):

tABLENAME'               => array(



				array('KLASSEID' => 'KLASSEID'),


'rEFERENZ'               => array(



				array('REFERENZID' => 'REFERENZID'),


tABLENAME would be the needed Table and .TABLENAME the value.

Any Ideas?


Hi Bunsu,

Please state your problem with a specific sample case … what tables do you have and what columns do they have … and what do you do with them.

Hey softark,

Thanks for your reply.

I have several Tables ( For example 4). One Table, i call it Table1, is at a higher level then the others and there are Tablenames for the other 3 Tables in it.

For Example:

Table1 looks like this:





Now there are other Tables with Tablenames like "PERSON" and "SUMMARY" and i need to build a dynamic relation in an other Model who is related with both Tables.

Hope this explain is a bit better.


I still don’t understand.

What ‘Name’ and ‘Value’ represent in Table1?

What relation do Table1 and PERSON have?

Probably you could show us some ER graph.



Hopefully this helps a little bit.

I have the Table “Class” where all “Refernces” Table’s stands in.

In another Table "Management" i have a refernece to "Classtable" and a reference to "RefernceTable".

Now I want to pick out values of the Refernence Table.

For this i first need to pick the tablename Value in the “Classtable” who is refernced with the managementtable’s ClassID.

Then i can pick the right Table and choose the Value of the Reference Table with the relation ReferenceID.


Thanks, I’ve got a vague idea of what you are trying to do.

Well, I’m not an expert in data handling (including relational database). So I might be wrong, but it looks to me that it’s very difficult and ineffective for relational databases to handle this kind of related data.

I’m afraid you won’t be able to make use of the “relation” of CActiveRecord here.

Yes i know that, but we have to use the database as she is, so we have no possibility

to change it. I just hoped there is any way to handle this in relations.

Thanks and great Weekend


Check this: