Yii Framework Forum: CDbCriteria compare with another column, not value - Yii Framework Forum

Jump to content

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

CDbCriteria compare with another column, not value Rate Topic: -----

#1 User is offline   vassy 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 28
  • Joined: 14-October 09

Posted 10 July 2010 - 06:03 AM

Hello.

I need to run a complex search using CDbCriteria and at some point it should compare not with a fixed value, but with another column value.
Ex.:
$criteria->compare('column1','>column2');
where column1 and column2 are MySQL table columns.
I've tried
$criteria->compare('column1',new CDbExpression('>column2'));
but it doesn't work.

Please help.

Thank you.
0

#2 User is offline   num 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 06-July 10

Posted 10 July 2010 - 03:51 PM

try
$criteria->addCondition('column1 > column2');
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