I am getting the following error
Fatal error: Call to undefined method MongoCollection::command() in /home/cr47/public_html/methods.php on line 67
when I try to get unique records from the MongoDB I am working with.
I have the code listing all of my records correctly but I don't want to list duplicates. So I changed my list Records function from this(works but lists "Butter" 20 times instead of once):
public function listRecords($query = null){
$this->find($query);
foreach($this->cursor as $record) {
$ing = $record['Shrt_Desc'];
echo '<a href="find.php?Shrt_Desc=' . $ing .'"> ' . $ing . ' </a> </br>';
}
}
I modified the above function(in an attempt to make "Butter" only list once):
public function listRecords($query = null){
$this->find($query);
foreach($this->cursor as $record) {
//$ing = $record['Shrt_Desc'];
$ing = $this->command(array("distinct" => "record", "key" => "Shrt_Desc"));
echo '<a href="find.php?Shrt_Desc=' . $ing .'"> ' . $ing . ' </a> </br>';
}
}
Here is the distinct.php
page where I instantiate my classes and call my functions:
include ("methods.php");
$csvCommands = new csvCommands();
$csvCommands->listRecords();