Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Problema Con Through

$
0
0
Hola a todos,

Estoy intentando hacer una relación HAS_MANY y tengo un error. Me explico rápidamente:

Tengo un model 'User' que se relaciona con 'Job' y con 'JobMessage' a través de 'Job'.

//en relations() de User
...
'jobs' => array(self::HAS_MANY, 'Job', 'author_id'),
'jobmessages' => array(self::HAS_MANY, 'JobMessage', array('id'=>'job_id'),'through' => 'jobs'),
...

la pk y fk son

tbl_Job.author_id -> tbl_User.id
tbl_Job.id -> tbl_JobMessage.job_id


Pues bien el error que recibo es:

PHP Error

preg_split() expects parameter 2 to be string, array given


630                 foreach($params as $name=>$value)
631                     $query->params[$name]=$value;
632             }
633             else
634                 throw new CDbException(Yii::t('yii','The relation "{relation}" in active record class "{class}" is specified with an incomplete foreign key. The foreign key must consist of columns referencing both joining tables.',
635                     array('{class}'=>get_class($parent->model), '{relation}'=>$this->relation->name)));
636         }
637         else
638         {
639             $element=$this;
640             while($element->slave!==null)
641             {
642                 $fks=preg_split('/\s*,\s*/',$element->relation->foreignKey,-1,PREG_SPLIT_NO_EMPTY);
643                 if($element->slave->slave===null)
644                 {
645                     $fke=$element->slave;
646                     $pke=$element;
647                 }
648                 else // nested through detected
649                 {
650                     $fke=$element;
651                     $pke=$element->slave;
652                 }
653                 $query->joins[]=$element->slave->joinOneMany($fke,$fks,$pke,$parent);
654                 $element=$element->slave;



¿Alguna idea?

Gracias

Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>