Category: mongodb

  • PHP, MongoDB, findAndModify

    findAndModify is not supported by the current version of the PHP MongoDB driver, so I had to use the following code $feed = $db->command(array(‘findAndModify’ => ‘feedList’, ‘query’ => array(‘$where’ => new MongoCode(‘ function(){ return ((this.inProgress == false) || (currentTime >= (this.lastUpdated + this.updateFrequency)))); }’, array(‘currentTime’ => $start))), ‘update’ => array(‘$set’ => array(‘inProgress’ => true)))); Where:…