0

I put mongo on my Mac using copying mongo.so for both 5.2 and 5.4 mongoCollection doesnt have aggregate method!!!! I tested the same php on my aws and that works there

I tried var_dump(get_class_methods('MongoCollection')); and on my local:

array (size=24)
0 => string '__construct' (length=11)
1 => string '__toString' (length=10)
2 => string '__get' (length=5)
3 => string 'getName' (length=7)
4 => string 'getSlaveOkay' (length=12)
5 => string 'setSlaveOkay' (length=12)
6 => string 'drop' (length=4)
7 => string 'validate' (length=8)
8 => string 'insert' (length=6)
9 => string 'batchInsert' (length=11)
10 => string 'update' (length=6)
11 => string 'remove' (length=6)
12 => string 'find' (length=4)
13 => string 'findOne' (length=7)
14 => string 'ensureIndex' (length=11)
15 => string 'deleteIndex' (length=11)
16 => string 'deleteIndexes' (length=13)
17 => string 'getIndexInfo' (length=12)
18 => string 'count' (length=5)
19 => string 'save' (length=4)
20 => string 'createDBRef' (length=11)
21 => string 'getDBRef' (length=8)
22 => string 'group' (length=5)
23 => string 'distinct' (length=8)`

and on aws:

array(28) { [0]=> string(11) "__construct" [1]=> string(10) "__toString" [2]=> string(5) "__get" [3]=> string(7) "getName" [4]=> string(12) "getSlaveOkay" [5]=> string(12) "setSlaveOkay" [6]=> string(17) "getReadPreference" [7]=> string(17) "setReadPreference" [8]=> string(4) "drop" [9]=> string(8) "validate" [10]=> string(6) "insert" [11]=> string(11) "batchInsert" [12]=> string(6) "update" [13]=> string(6) "remove" [14]=> string(4) "find" [15]=> string(7) "findOne" [16]=> string(13) "findAndModify" [17]=> string(11) "ensureIndex" [18]=> string(11) "deleteIndex" [19]=> string(13) "deleteIndexes" [20]=> string(12) "getIndexInfo" [21]=> string(5) "count" [22]=> string(4) "save" [23]=> string(11) "createDBRef" [24]=> string(8) "getDBRef" [25]=> string(5) "group" [26]=> string(8) "distinct" [27]=> string(9) "aggregate" }

when I use aggregate on terminal(local) it works

seems very weird, any idea is appreciated.

Neil Lunn
  • 148,042
  • 36
  • 346
  • 317
zarehb
  • 21
  • 7

1 Answers1

0

MongoCollection::aggregate (PECL mongo >=1.3.0)

As such - you are using the driver version >= 1.3.0 on aws, and < 1.3.0 on your mac.

Note that aggregation was introduced in monogoDB version 2.2

AD7six
  • 63,116
  • 12
  • 91
  • 123
  • i guess this is about mongo.so not the mongo installation itself – zarehb Mar 10 '13 at 08:33
  • I think I can live with command http://stackoverflow.com/questions/11290809/mongodb-aggregation-php for now – zarehb Mar 10 '13 at 08:34
  • Upgrading pecl mongo to match the version used on the server would be a more logical conclusion – AD7six Mar 10 '13 at 09:10
  • not sure how can I get the pecl mongo version; also can I update it or I will have to reinstall it, thanks – zarehb Mar 10 '13 at 09:54
  • got it ; it is in phpinfo() Mongo section – zarehb Mar 10 '13 at 10:03
  • I think I have to post this in a separate thread, but also I paste it here; now there is another issue aws is 2.2.3 a simple aggregate on mongo shell causes this { "errmsg" : "no such cmd", "ok" : 0 } but it works fine on local; any idea? – zarehb Mar 10 '13 at 10:17
  • sounds like a mongoDB version mismatch. I.e. you're _not_ using mongo version 2.2+ on aws. `mongo --version` or `> version()` will tell you – AD7six Mar 10 '13 at 17:20
  • this is what I am getting there: mongo --version MongoDB shell version: 2.2.3 – zarehb Mar 10 '13 at 19:05
  • will post more if I figure out the reason – zarehb Mar 10 '13 at 19:05
  • got it, the db version is wrong on aws not sure why; when I run mongod it shows db version v1.0.1 ; going to reinstall – zarehb Mar 10 '13 at 19:19