diff --git a/src/Xhgui/Profiles.php b/src/Xhgui/Profiles.php index 70aefdf..8ff07d9 100644 --- a/src/Xhgui/Profiles.php +++ b/src/Xhgui/Profiles.php @@ -8,6 +8,11 @@ class Xhgui_Profiles protected $_mapper; + /** + * @var MongoId lastProfilingId + */ + private static $lastProfilingId; + public function __construct(MongoDb $db) { $this->_collection = $db->results; @@ -22,6 +27,18 @@ public function __construct(MongoDb $db) */ public function insert($profile) { + $profile['_id'] = self::getLastProfilingId(); return $this->_collection->insert($profile, array('w' => 0)); } + + /** + * Return profiling ID + * @return MongoId lastProfilingId + */ + public static function getLastProfilingId() { + if (!self::$lastProfilingId) { + self::$lastProfilingId = new MongoId(); + } + return self::$lastProfilingId; + } }