MongoDB からデータを収集して出力する PHP スクリプトがあります。いくつかのオプションは$_POST
スーパーゴブラルから収集されます。すべて正常に動作しますが、配列を使用してフィールドを返すように制限することはできません。
$results = $db->$table->find($param); //This line works and returns all fields
$results = $db->$table->find($param, array('Descripción','Ocurrencias relacionadas'));//This line works and limit the returned fields to the ones specified.
次のコードは、フィールド リミッタ パラメーターとして使用する配列を構築します。
$fields=implode(',', $_POST[field]);
$fd = array($fields);
print_r($fd)
ショー:
Array ( [0] => 'Descripción','Ocurrencias relacionadas' )
$results = $db->$table->find($param,$fd);` //This line works and returns all documents but only _id field.
何か案は?それは私を怒らせています!前もって感謝します。