Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7740455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:46:59+00:00 2026-06-01T08:46:59+00:00

I am getting the following error Fatal error: Call to undefined method MongoCollection::command() in

  • 0

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();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T08:47:01+00:00Added an answer on June 1, 2026 at 8:47 am

    I think the problem is that you are calling $this->find($query) are you sure you have a method called find or you are trying to call MongoDB find method it should be something like $this->db->find or $this->mongoDB->find

    I think is better to upload your full call so that we can look at it better if you are still having issues

    Edit 1

    Replace

    $this->command
    

    With

    $this->connection->command
    

    Thanks

    🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Why am I getting the following error? Fatal error: Call to undefined method mysqli_stmt::query()
I am getting the following error: Fatal error: Call to undefined method MDB2_Error::quoteIdentifier() The
I am getting the following error on line 17 Fatal error: Call to a
I'm using PHP 5.2 and getting the following error message: Fatal error: Call to
When submitting the following form I am getting this error : Fatal error: Call
With vBulletin in PHP, I'm getting this error Fatal error: Call to a member
I am getting the following error with my drupal website. Fatal error: Call to
I am getting the following PHP Fatal Error Fatal error: Uncaught exception 'Exception' with
Getting the following the error : Fatal error: Call to a member function load()
Suddenly I started getting the following error: Fatal error: Class 'Mongo' not found in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.