bobthecow / genghis

The single-file MongoDB admin app
http://genghisapp.com
MIT License
1.45k stars 165 forks source link

error when updating document #188

Closed Nours312 closed 10 years ago

Nours312 commented 10 years ago

I can't update any documents . On the request $this->collection->update($query, $doc, self::safe())
$doc is stdclassObject but php plugin need an Array $this->collection->update($query, (array)$doc, self::safe()) resolve it.

Genghis Version 2.3.11 PHP 5.5.9-1ubuntu4.4 Apache/2.4.7 mongod db version v2.6.4 PECL : mongo 1.5.1 stable

If you want more informations about my configuration or options tell me.

bobthecow commented 10 years ago

I just tested with this setup and it worked perfectly:

>>> PHP_VERSION
=> "5.5.15"
>>> GENGHIS_VERSION
=> "2.3.11"
>>> Mongo::VERSION
=> "1.5.4"

The second argument to MongoCollection::update should take either an array of fields or an object. Maybe the driver v1.5.1 had an issue that they fixed by 1.5.4?

bobthecow commented 10 years ago

@jmikola poke ;)

bobthecow commented 10 years ago

The signature for MongoCollection::update in v1.5.4 is this:

public function update($old_array_of_fields_OR_object, $new_array_of_fields_OR_object, array $options = ?)
jmikola commented 10 years ago

Possibly PHP-1084, which was fixed with mongodb/mongo-php-driver#685 in 1.5.2.

bobthecow commented 10 years ago

Yep. That looks about right. Thanks @jmikola

@Nours312 Update to a newer version of the mongo driver and you're set!