Yii Framework Forum: Can I use array('ordering'=>'ordering+1') in the updateAll? - Yii Framework Forum

Jump to content

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

Can I use array('ordering'=>'ordering+1') in the updateAll? Rate Topic: -----

#1 User is offline   holala 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 74
  • Joined: 23-December 09

Posted 20 January 2010 - 11:57 PM

I tried,but faild.

$this->model->updateAll(array('ordering'=>'ordering+2'));


I want this:
UPDATE article SET ordering=ordering+1;


Please help!

Thanks!
0

#2 User is offline   holala 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 74
  • Joined: 23-December 09

Posted 21 January 2010 - 12:31 AM

solved by myself

use this:
$this->model->updateAll(array('ordering'=>new CDbExpression('ordering+2')));


this's work.
0

#3 User is offline   ricardograna 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 378
  • Joined: 31-March 09
  • Location:Manaus/AM - Brazil

Posted 22 January 2010 - 07:01 AM

$this->model->updateCounters(array('ordering'=>2));

Yes, It Is!
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