Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Undefined index: result" - When calling Model aggregation methods #44

Closed
jmshelby opened this issue Oct 3, 2013 · 1 comment
Closed

Comments

@jmshelby
Copy link

jmshelby commented Oct 3, 2013

When I try to call any of the Model's aggregate functions (static calls to count, min, max, sum ...) I get this error message from the Builder.

image

In this example I have a simple class called Characters extending your base model, and its empty (no specialization code). Here is the logged output of the results array from the call to collection->aggregate()

(
    [errmsg] => no such cmd: aggregate
    [bad cmd] => Array
        (
            [aggregate] => characters
            [pipeline] => Array
                (
                    [0] => Array
                        (
                            [$group] => Array
                                (
                                    [_id] => 
                                    [*] => Array
                                        (
                                            [$sum] => 1
                                        )

                                )

                        )

                )

        )

    [ok] => 0
)

@jmshelby
Copy link
Author

jmshelby commented Oct 3, 2013

Okay -- digging into this more, it turns out that the aggregate function in MongoDB is new as of version 2.2 (of the mongod service). So if you're using this package, you'll want make sure you're using the latest version of the service.

@jenssegers --> Might be good to add this to the documentation ;)

If you're on ubuntu, like I am, you need to install from the 10Gen aptitude repo, as the default one (just using apt-get install mongodb) will give you a quite older version, 2.0.4 in my case.

http://docs.mongodb.org/manual/reference/method/db.collection.aggregate/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant