Created
December 5, 2012 17:48
-
-
Save jrschumacher/4217850 to your computer and use it in GitHub Desktop.
MongoId to handle psudo MongoId objects (especially when dealing with json)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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