Special relation

I would like to have a relation like:

ON (CONCAT(‘sometext_’,t.id) == rel.itemId)

Nothing more.

Can i do this in the AR?

Thanks :slight_smile:

try with "on clause"

see this http://www.yiiframework.com/forum/index.php?/topic/4148-ar-relation-foreign-key/

Doesn’t work, as it always requires me to choose a column for the relation.

You can put your relations function code here?

you have to put ’ ’ where is the column name

and use clause ‘with’ in the find method (not lazy loading)

in the model





'mySpecialRelation'=>array(self::BELONGS_TO,'TableRel','','on'=>'CONCAT(\'sometext_\',`t`.`id`) = `rel`.`itemId`','alias'=>'rel'),




in the controller




  $models=ModelName::model()->with('mySpecialRelation')->findAll();



[edit]

it’s work on 1.0.x