开发者

Compare two Doctrine_Record objects

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

On the domain login I am considering, t开发者_运维知识库wo objects are equal if they have the same properties values, except the id and the created_at and updated_at fields (a la Timestampable).


First idea which comes into my mind is:

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;
  }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜