Yii Framework Forum: Defining Jointype On Many_Many Relation - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Defining Jointype On Many_Many Relation Rate Topic: -----

#1 User is offline   FrancisB 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 28-November 12

Posted 04 March 2014 - 02:06 AM

Hi, I'm not sure if this is a bug or not so I'm posting it here first.

I have defined the following relation in my User model

'ActiveNotifications' => array(self::MANY_MANY, 
	'Notification', 'UserNotifications(user_id, notification_id)',
	'condition'=>'notification_id is null',
	'joinType' => 'LEFT JOIN',
),


With this relation I am attempting to find all notifications that have not been viewed by a user. I am using the join table "UserNotifications" to define that the user HAS seen a particular notification. So therefore want this relation to grab all notifications NOT IN the join table for a particular user.

Looking at CActiveFinder.php line 605 it has this

$join='INNER JOIN '.$joinTable->rawName.' '.$joinAlias.' ON ';


Changing this line to

$join=$this->relation->joinType.' '.$joinTable->rawName.' '.$joinAlias.' ON ';


fixes the problem. There is also a hard coded "INNER JOIN" at line 1610, but this wasn't causing a problem in my case.

There are other ways I could solve my unseen notification problem, but I just thought that this might still be considered a bug.

This is on Yii version 1.1.14

Cheers,
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

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