调用mongodb command接口查询返回的objectid是一个对象
"_id": {
"timestamp": 1499995789,
"machineIdentifier": 11168948,
"processIdentifier": -31655,
"counter": 11459245,
"time": 1499995789000,
"date": 1499995789000,
"timeSecond": 1499995789
},
为了获得字符串格式的objectid,特意研究了下objectId的bson结构
了解了object Bson很容易得出一个php的转换代码
//转换objectid
public function convertId($objectid){
$ret ="";
$ret.= dechex($objectid['timestamp']);
$ret.= dechex($objectid['machineIdentifier']);
$ret.= substr(dechex($objectid['processIdentifier']),-4) ;
$ret.= dechex($objectid['counter']);
return $ret;
}