I have a PHP script that gathers data from MongoDB and prints it. Some options are gathered from $_POST
supergoblal. Everything works fine but I can't limit the fields to return using an array.
$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.
The following code constructs an array to use as a field limiter parameter:
$fields=implode(',', $_POST[field]);
$fd = array($fields);
print_r($fd)
shows:
Array ( [0] => 'Descripción','Ocurrencias relacionadas' )
$results = $db->$table->find($param,$fd);` //This line works and returns all documents but only _id field.
Any ideas? It's driving me mad! Thanks in advance.