Skip to content

Instantly share code, notes, and snippets.

@jrschumacher
Created December 5, 2012 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrschumacher/4217850 to your computer and use it in GitHub Desktop.
Save jrschumacher/4217850 to your computer and use it in GitHub Desktop.
MongoId to handle psudo MongoId objects (especially when dealing with json)
<?php
class MongoId2 extends MongoId {
public function __construct($id = null) {
if(is_array($id)) {
$id = (object) $id;
}
if(is_object($id) && isset($id->{'$id'})) {
$id = $id->{'$id'};
}
return parent::__construct($id);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment