Skip to content

Instantly share code, notes, and snippets.

@chrisguitarguy
Last active August 29, 2015 14:28
Show Gist options
  • Select an option

  • Save chrisguitarguy/f83cf02124181d717438 to your computer and use it in GitHub Desktop.

Select an option

Save chrisguitarguy/f83cf02124181d717438 to your computer and use it in GitHub Desktop.
Just some MongoDB PHP API Weirdness I guess?
<?php
$mongo = new \MongoClient();
$col = $mongo->testDb->testCollection;
$col->drop();
$col->insert(['test' => 'one']);
// works perfectly
var_dump(iterator_to_array($col->find([
'test' => 'one',
], ['test'])));
// requires fields to be `fieldName => true/false`
var_dump($col->findAndModify([
'test' => 'one',
], [
'$set' => ['test' => 'two'],
], ['test' => true], [
'upsert' => true,
'new' => true,
]));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment