Yii Framework Forum: Understanding Cactiverecord::saveattributes() - Yii Framework Forum

Jump to content

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

Understanding Cactiverecord::saveattributes() Rate Topic: -----

#1 User is offline   msoa 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 261
  • Joined: 15-August 12

Posted 18 August 2013 - 01:55 AM

Hi,
In definition parameters of CActiveRecord:saveAttributes($array attributes) coming:

Quote

$attributes array attributes to be updated. Each element represents an attribute name or an attribute value indexed by its name. If the latter, the record's attribute will be changed accordingly before saving.

What's the mean of this statement: If the latter, the record's attribute will be changed accordingly before saving. ???

0

#2 User is offline   nineinchnick 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 622
  • Joined: 12-September 11
  • Location:Bialystok, Poland

Posted 18 August 2013 - 02:00 AM

Two examples doing the same:
$model->attribute = 'new value';
$model->saveAttributes(array('attribute'));


$model->saveAttributes(array('attribute'=>'new value'));

Don't be a dick.
0

#3 User is offline   msoa 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 261
  • Joined: 15-August 12

Posted 18 August 2013 - 02:17 AM

View Postnineinchnick, on 18 August 2013 - 02:00 AM, said:

Two examples doing the same:
$model->attribute = 'new value';
$model->saveAttributes(array('attribute'));


$model->saveAttributes(array('attribute'=>'new value'));


I know it. what's mean of this statement: If the latter, the record's attribute will be changed accordingly before saving.
0

#4 User is offline   nineinchnick 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 622
  • Joined: 12-September 11
  • Location:Bialystok, Poland

Posted 18 August 2013 - 02:23 AM

The values passes in the argument will be assigned to attributes matching keys and then they will be saved.
That's why it's 'before being saved'. Because they are first assigned and then saved.
Don't be a dick.
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