Yii Framework Forum: CActiveDataProvider and CGridView relation field and condition join BUG - Yii Framework Forum

Jump to content

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

CActiveDataProvider and CGridView relation field and condition join BUG Seems to be a bug Rate Topic: ***** 2 Votes

#1 User is offline   romanoza 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 117
  • Joined: 17-April 09
  • Location:Moscow, Russia

Posted 25 March 2010 - 08:49 AM

Hi.

It seems to be a bug in 1.1.1

I have this:
$criteria=new CDbCriteria;
$criteria->with('someRelation');
$adp = new ActiveDataProvider('MyModel', array(
   'criteria'=>$criteria,
);

/* Widget code with $adp */


It's ok, SQL runs with join, but when I add condition:
$criteria=new CDbCriteria;
$criteria->with('someRelation');
$criteria->condition = 'someRelation.fieldId = 1';
$adp = new ActiveDataProvider('MyModel', array(
   'criteria'=>$criteria,
);

/* Widget code with $adp */

there is no join statement in SQL.

The only way I found is to use
$criteria->join = 'LEFT JOIN someRelation on MyModel.someRelationId = someRelation.id';


Is that bug or I did not understand something? :)
I am not a wizard, i am just learning...
0

#2 User is offline   Fran├žois Gannaz 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 87
  • Joined: 24-November 09

Posted 25 March 2010 - 01:25 PM

If your relation is a MANY_MANY, I think it's a bug. The same problem was reported in a previous post.

It seems to be related to bug 910, marked invalid even though the reporter did not agree.
0

#3 User is offline   romanoza 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 117
  • Joined: 17-April 09
  • Location:Moscow, Russia

Posted 26 March 2010 - 03:29 AM

View PostFran├žois Gannaz, on 25 March 2010 - 01:25 PM, said:

If your relation is a MANY_MANY, I think it's a bug. The same problem was reported in a previous post.

It seems to be related to bug 910, marked invalid even though the reporter did not agree.

It can be HAS_MANY too
I am not a wizard, i am just learning...
0

Share this topic:


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

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