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 :-)
Page 1 of 1
Special relation
#2
Posted 15 January 2010 - 07:40 AM
Thomas Jensen, on 14 January 2010 - 01:42 PM, said:
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 :-)
ON (CONCAT('sometext_',`t`.`id`) == `rel`.`itemId`)
Nothing more.
Can i do this in the AR?
Thanks :-)
try with "on clause"
see this http://www.yiiframew...on-foreign-key/
KISS - Keep It Simple Stupid
ASAP-As Soon As Possible
http://www.yiiframew...oc/cookbook/71/
http://hmsegura.blogspot.com/
ASAP-As Soon As Possible
http://www.yiiframew...oc/cookbook/71/
http://hmsegura.blogspot.com/
#3
Posted 17 January 2010 - 03:12 PM
Doesn't work, as it always requires me to choose a column for the relation.
#4
Posted 18 January 2010 - 10:48 AM
Thomas Jensen, on 17 January 2010 - 03:12 PM, said:
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
This post has been edited by Horacio Segura: 18 January 2010 - 10:50 AM
KISS - Keep It Simple Stupid
ASAP-As Soon As Possible
http://www.yiiframew...oc/cookbook/71/
http://hmsegura.blogspot.com/
ASAP-As Soon As Possible
http://www.yiiframew...oc/cookbook/71/
http://hmsegura.blogspot.com/
Share this topic:
Page 1 of 1

Help













