Yii Framework Forum: [SOLVED] updateByPk updates all rows? - Yii Framework Forum

Jump to content

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

[SOLVED] updateByPk updates all rows?

#1 User is offline   DarkNSF 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 287
  • Joined: 12-November 08
  • Location:Palm Bay, Florida

Posted 18 July 2011 - 11:33 AM

SOLUTION: Figured it out while writing this post :) It appears that the ';' in the expression cuts the query short. It makes sense that it would, I'm just surprised that I never encountered this earlier. Must pertain to a certain version of MySQL?

change 'NOW();'to 'NOW()'



seems to have a slight issue with updating a date column..

here is my code that is just running in route site/test (to try to minimize other possibilities)





  public function actionTest()
  {
    $now = new CDbExpression('NOW();');
    Lead::model()->updateByPk(57, array('dateModified'=>$now));
  }



After this code runs, every lead table in the database has the same dateModified (NOW();). Any ideas?
1

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