Yii Framework Forum: Many to Many - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

Many to Many Rate Topic: -----

#1 User is offline   Boris 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 26
  • Joined: 05-December 08

Posted 08 December 2008 - 04:59 PM

Hi,

i am trying to realize a many to many relationship with one two tables.
User -> user_fried -> User

Actually i am facing troubles in the CActiveFinder in the method getJoinCondition. This is because the childCondition does not get recognized. Both definition are taken as parent table.

Does somebody know if this is possible somehow? PHPDoctrine can do that :-( It would be nice if someone has a solution.

Thanks
Bye
0

#2 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,892
  • Joined: 04-October 08
  • Location:DC, USA

Posted 08 December 2008 - 05:17 PM

Could you please create a ticket for this? This should be supported, but there's a bug when handling this particular scenario.
0

#3 User is offline   Boris 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 26
  • Joined: 05-December 08

Posted 08 December 2008 - 05:23 PM

I did a quick test...

foreach($fks as $fk)
{$i++;
if(isset($joinTable->foreignKeys[$fk]))
{
list($tableName,$pk)=$joinTable->foreignKeys[$fk];
if($i==1 && $schema->compareTableNames($parent->_table->rawName,$tableName))
$parentCondition[]=$parent->getColumnPrefix().$schema->quoteColumnName($pk).'='.$joinAlias.'.'.$schema->quoteColumnName($fk);
else if($schema->compareTableNames($this->_table->rawName,$tableName))
$childCondition[]=$this->getColumnPrefix().$schema->quoteColumnName($pk).'='.$joinAlias.'.'.$schema->quoteColumnName($fk);


so that the first is parent, the second child, everything seemed to work, now is up to you to make it a beautiful code :)

Ok i create a ticket.

Thanks.

I have one more question, but i will post it in an own thread.
0

#4 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,892
  • Joined: 04-October 08
  • Location:DC, USA

Posted 08 December 2008 - 05:59 PM

Thanks. Fix checked in.
0

#5 User is offline   Boris 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 26
  • Joined: 05-December 08

Posted 08 December 2008 - 07:17 PM

That was realy fast ;-) Thanks, i checked it. It worked. Lets see....
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users