Open GurjinderSingh opened 10 years ago
i m inserting some numeric values in db. when i check them in rockmongo they totally different but when i access them from php/mongo shell they are fine.
Update 1 : installed new from git hub but problem is same Update 2 : found the location where data is changing for float its var_export function of php https://github.com/iwind/rockmongo/blob/c7e1f42f764cde03b1147b96d7926c10994334c3/app/classes/VarExportor.php#L48
http://php.net/manual/en/function.var-export.php#113770
<?php $DB_con = new \MongoClient(); $DB_db = $DB_con->selectDB('mydb'); $DB_col = $DB_db->selectCollection('col'); $DB_col->insert(array('1'=> 2.4, '2'=> 1.3, '3'=> 1.7, '4'=> 0.2, '5'=> 1.1, '6'=> 1.3, '7'=> 1.0, '8'=> 1.5, '9'=> 1.7, '10'=> 1.9, '11'=> 2.3, '12'=> 2.39, '13'=> 2.40, '14'=> (double)2.41, '14-1'=> (double)2, '15'=> (float)2.41, '15-1'=> (float)2, )); ?>
<php var_dump($DB_col->findOne(array ('_id' => new \MongoId("542009ac92dd951d5c8b4567")))); ?>
array(18) { ["_id"]=> object(MongoId)#7 (1) { ["$id"]=> string(24) "5420102292dd95135d8b4567" } [1]=> float(2.4) [2]=> float(1.3) [3]=> float(1.7) [4]=> float(0.2) [5]=> float(1.1) [6]=> float(1.3) [7]=> float(1) [8]=> float(1.5) [9]=> float(1.7) [10]=> float(1.9) [11]=> float(2.3) [12]=> float(2.39) [13]=> float(2.4) [14]=> float(2.41) ["14-1"]=> float(2) [15]=> float(2.41) ["15-1"]=> float(2) }
mydb.col.find( { '_id':ObjectId("54200c5092dd95a85c8b4567")}); { "_id" : ObjectId("54200c5092dd95a85c8b4567"), "1" : 2.4, "2" : 1.3, "3" : 1.7, "4" : 0.2, "5" : 1.1, "6" : 1.3, "7" : 1, "8" : 1.5, "9" : 1.7, "10" : 1.9, "11" : 2.3, "12" : 2.39, "13" : 2.4, "14" : 2.41, "14-1" : 2, "15" : 2.41, "15-1" : 2 }
array ( '_id' => new MongoId("54200c5092dd95a85c8b4567"), 1 => 2.3999999999999999, 2 => 1.3, 3 => 1.7, 4 => 0.20000000000000001, 5 => 1.1000000000000001, 6 => 1.3, 7 => 1, 8 => 1.5, 9 => 1.7, 10 => 1.8999999999999999, 11 => 2.2999999999999998, 12 => 2.3900000000000001, 13 => 2.3999999999999999, 14 => 2.4100000000000001, '14-1' => 2, 15 => 2.4100000000000001, '15-1' => 2, )
{ "_id": ObjectId("54200c5092dd95a85c8b4567"), "1": 2.4, "2": 1.3, "3": 1.7, "4": 0.2, "5": 1.1, "6": 1.3, "7": 1, "8": 1.5, "9": 1.7, "10": 1.9, "11": 2.3, "12": 2.39, "13": 2.4, "14": 2.41, "14-1": 2, "15": 2.41, "15-1": 2 }
i m inserting some numeric values in db. when i check them in rockmongo they totally different but when i access them from php/mongo shell they are fine.
Update 1 : installed new from git hub but problem is same Update 2 : found the location where data is changing for float its var_export function of php https://github.com/iwind/rockmongo/blob/c7e1f42f764cde03b1147b96d7926c10994334c3/app/classes/VarExportor.php#L48
http://php.net/manual/en/function.var-export.php#113770
test php file
test find code change id please
output ::
find output in mongo shell
output in rock mongo query type php
output in rock mongo query type JSON