Yii Framework Forum: model instances equality - Yii Framework Forum

Jump to content

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

model instances equality Rate Topic: -----

#1 User is offline   augustin 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 43
  • Joined: 07-April 10

Posted 15 April 2010 - 03:29 AM

what is the best way of checking if two model instances are equal (all attributes have exactly the same values, maybe with the exception of the primary key (it may be e.g. null in one case))
0

#2 User is offline   vamp 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 181
  • Joined: 30-January 09

Posted 15 April 2010 - 04:41 AM

default method is:

$someModel->equals( $anotherModel );

but you can override it to check attributes (using array_diff function)
-Posted Image-
Thanks, you make me stronger!
0

#3 User is offline   augustin 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 43
  • Joined: 07-April 10

Posted 16 April 2010 - 12:30 PM

thank you!
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