coen-hyde/Shanty-Mongo — Issue #58: Comparisons on 'stuff'
Author: tonymillion
Created: 2011-12-22 19:16:50+00:00
State: open

I have a blog system with 'User' objects. Users can either post or comment. A poster can comment on their own post.

In both posts and comments I have

```php
class Comment extends Shanty_Mongo_Document
{
protected static $_requirements = array(
'user' => array('Document:User', 'AsReference'),

class Post extends Shanty_Mongo_Document
{
protected static $_requirements = array(
'user' => array('Document:User', 'AsReference'),
'comments' => 'DocumentSet',
'comments.$' => 'Document:Comment',
```

in my code I was coding a system that sends a notification to the writer of a Post and to all the Commenters on a Post. Obviously if a poster has commented on their post I don't want them getting two notifications so I did something like:

```php
foreach($post->comments as $comment)
{
if($post->user == $comment->user)
```
however the comparison fails … if I do

```php
if($post->user->getID() == $comment->user->getID())
```

it succeeds.

Is this correct operation? Am I doing something wrong?