2017-12-04 17 views
0

PHPのMongoDBから_idフィールドを除外しようとしています。result.belowは私のPHPスクリプトです。スクリプトから_idを出力から除外することができます。PHPの結果mongodb _idフィールドを除外する方法

<?php 
try 
{ 
    $connection = new Mongo('mongodb://user:[email protected]:xxxxx/stats'); 
    $database = $connection->selectDB('stats'); 
    $collection = $database->selectCollection('stat'); 
} 
catch(MongoConnectionException $e) 
{ 
    die("Failed to connect to database ".$e->getMessage()); 
} 

$cursor = $collection->find(); 

echo json_encode(iterator_to_array($cursor)); 



?> 

答えて

1

追加: - 見つける...

+0

$cursor->fields(array('_id'=>false)); 

Worked.Thankそんなにそれはです。 –

+0

問題はありません。あなたは答えを受け入れることができるので、ポイントを得ることができますか(彼らが意味するものは分かりません)。乾杯... –

関連する問題