Compare two Doctrine_Record objects

How to compare two Doctrine_Record objects to see if they are "equal"?

In my domain login, two objects are equal if they have the same property values, except for the fields id and created_at and updated_at (a la Timestampable ).

+2
source share
1 answer

The first thought that comes to my mind:

 class User extends Doctrine_Record { public function equals(User $user) { $left = $this->toArray(); $right = $user->toArray(); unset($left['id'], $left['created_at'], $left['updated_at']); unset($right['id'], $right['created_at'], $right['updated_at']); return $left == $right; } } 
+1
source

Source: https://habr.com/ru/post/885746/


All Articles